i am just wondering 'bout use of Logger API in Utility classes while writing java code. we can always use logger where we will be using our utility class to log a proper message BUT what i want to ask is--
Is it a good practice to use Logger in utility classes?
I assume you are writing your own *Util code.
Personally I avoid using Logger in utility classes, because of the "noise" in the log files. If your utility class is well tested, you may remove the log statements.
Just remember to only log, and not perform any business logic in the log statement (whether utility class or not).
E.g. I saw below in one of my projects, and this is not good practice.
log.info("Added = " + list.add("someString"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With