Search code examples
javalog4jpojo

In basic java POJOs, is log4j.Logger overkill?


What is the convention/tradition? Loggers in every class for completeness?


Solution

  • This is really opinion based, but for what it's worth I use loggers only when I need to log functionality for debugging/info/error purposes.

    For example if your class has a set of properties and returns a collection of those properties you likely do not need to add a logger, but if you add methods to manipulate the data prior to returning the collection you may want to add a logger to expose the data during the manipulation phase.

    That being said - its up to you to determine what needs to be logged. But I don't see a point in adding a logger if it's not going to be used...