logging in scala
- by IttayD
In Java, the standard idiom for logging is to create a static variable for a logger object and use that in the various methods.
In Scala, it looks like the idiom is to create a Logging trait with a logger member and mixin the trait in concrete classes. This means that each time an object is created it calls the logging framework to get a logger and also the object is bigger due to the additional reference.
Is there an alternative that allows the ease of use of "with Logging" while still using a per-class logger instance?
EDIT: My question is not about how one can write a logging framework in Scala, but rather how to use an existing one (log4j) without incurring an overhead of performance (getting a reference for each instance) or code complexity. Also, yes, I want to use log4j, simply because I'll use 3rd party libraries written in Java that are likely to use log4j.