[Lift] Re: SLF4J Logging for my classes

2009-10-23 Thread aw

Sure, I could create a trait as you suggested...  But, this sounds
like a common problem -- does this not already exist?  I see
discussions about adding it to Scala, but I don't think it exists.
And Lift already has a logging infrastructure (i.e. LogBoot as you
suggest).  Does it not make sense to add this trait to lift-util or
lift-common?  (I just want to avoid recreating the wheel.)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: SLF4J Logging for my classes

2009-10-22 Thread Jeppe Nejsum Madsen

aw anth...@whitford.com writes:

 I am using SLF4J logging, but I am not sure if I am doing it the
 right way...

 I have pointed Lift to use SLF4J, and I call the enable routine and
 have updated dependencies.  All of that seems fine.

 My question is around, how do my classes best use it...  For example,
 I am generally doing something like:

 import org.slf4j.{Logger, LoggerFactory}
 class Foo {
 private val LOGGER = LoggerFactory.getLogger(getClass)
 ...
 }

 Is this what one would expect?  Or is there a Lift Way that
 obsoletes the above?

I suggest using Lift's Logger (it can be configured to use slf4j,
search the archives for details). It has the nice feature that the log
message is lazily evaluated, so you don't have to litter your code with

if(log.isDebugEnabled) log.debug(...)

Also, I create a trait:

trait Logging {
  val log = LogBoot.loggerByName(this.getClass.getName)
}

This makes it easy to have logging in a class:

class myclass extends MyParent with Logging {
  log.debug(logggin stuff)
}

/Jeppe

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---