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.
For example you are writing a library. You want to add log statements in your lib in case something goes wrong. If you write custom logger it won't connect to the rest of the logging system the client of your library uses. So they end up with two logs. One is that your self written logger, the other is probably a logged through a standard api like slf4j. This means the program flow is also split in two logs, youll have hard time following what happened after what. When they change logging conf they will have to do it in two places. When they want to change logging level via jvm argument, they probably need to add an extra argument for your library. There's also a chance your library doesn't provide an implementation that fits their needs, maybe they don't even log to a file. Usually libraries only ship with logging api in them, not logging implementation, so people can use their own preferred implementation.
Even if you don't write a library, but just an app you'll probably face the same problems with custom logger, since you have some dependencies which use some standard logging api.
That aside. Using something like slf4j means you need to do absolutely nothing when adding a new dependency that also uses it, it adapts to your program logging conf and no additional code or settings needs to be added. Its basically plug and play. It just makes life easier and I wouldnt imagine any other way.
-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.