Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LazyLogging vs StrictLogging

I am using scala-logging. There are two classes LazyLogging and StrictLogging. I see, that the difference between them is that LazyLogging is initialized lazily. What is the purpose of that. When I should use one over the other and why?

like image 518
rarry Avatar asked Dec 19 '16 11:12

rarry


People also ask

What is LazyLogging?

trait LazyLogging extends AnyRef Defines logger as a lazy value initialized with an underlying org. slf4j. Logger named according to the class into which this trait is mixed.

What is logger in Scala?

Scala-logging is a library that wraps the Simple Logging Facade for Java (SLF4J) in a Scala-friendly library. SLF4J supports many different logging frameworks, including both log4j, which we've covered in an earlier post, and logback a similar framework.


1 Answers

Best always use StrictLogging. LazyLogging for when you want to postpone Logger initialization.

like image 63
analytically Avatar answered Sep 30 '22 01:09

analytically