logging in scala

I’d just stick to the “with Logging” approach. Clean design wins every time – if you get the boilerplate out the way then chances are that you can find far more useful gains achievable in other areas.

Keep in mind that the logging framework will cache loggers, so you still have one per class, even if every instance of that class happens to hold a (inexpensive) reference.

Without proof that logger references are harming your heap, this smells a lot like premature optimization… Just relax and don’t worry about it, unless a profiler tells you otherwise.

On an unrelated note, you might also want to look into using slf4j and logback instead of log4j. slf4j has a cleaner design that fits better with idiomatic scala.

Leave a Comment

tech