Consider the below code which uses scala logging:
class MyClass extends LazyLogging {
logger.debug("This is very convenient")
}
What is the difference if I use StrictLogging instead? When should I use which?
Edit: I know what lazy is. But I am unable to get it from logging perspective and how does it differ from its functionality when compared to strict logging. This is so that I can understand when to use which one.
I'm assuming you're refering to typesafes scala-logging library. The difference is only in the way logger
is defined by the underlying logger, it can either be defined as a normal value, or a lazy value, meaning:
trait LazyLogging {
@volatile protected lazy val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
}
vs
trait StrictLogging {
protected val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
}