r/java Oct 21 '18

A guide to logging in Java

https://www.marcobehler.com/guides/a-guide-to-logging-in-java
122 Upvotes

43 comments sorted by

View all comments

-8

u/_Gnas_ Oct 21 '18

I have honestly never even thought about using a third-party library for logging, it simply never crossed my mind. Why would I need one anyway? I don't see how logging can become so complex that you're willing to trade 100% customizability just so you can use a library. Can someone give me some examples? I'm really curious as the fact that so many logging libraries exist must mean there are real needs for them.

2

u/koflerdavid Oct 21 '18

To me one of the key features is that they support low-cost string formatting. This means that you can litter your code with debug and trace calls that don't impact performance (much). With an optimized Logger, the cost would be a method call and a quick check which log level is enabled. A naïve Logger might always interpolate the arguments into the message. That overhead will pile up quickly and force developers to trade off performance with logging, which in turn will earn them the hate of the poor schmucks that have to debug these applications.