0

For my application logs for a REST server, I'd like to log some details about each http request. I'm using sl4j. Should I use logger.debug or logger.info

More generally what sort of things should be logged in logger.info?

  • It might interest. Short and concise. – Laiv Jan 22 at 19:04
1

https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html defines the intended meanings of the levels and also explains that the ordering is OFF, FATAL, ERROR, WARN, INFO, DEBUG and ALL.

INFO is informational messages that highlight the progress of the application at coarse-grained level.. This sounds like what you are describing; you want to know what happened in the normal run of events

DEBUG is fine-grained informational events that are most useful to debug an application.. I reserve this for debugging, ie. something has gone wrong and you need to log something fine-grained, not just the error. I find it rare to put this in at the beginning of a code-base and more likely to go into a patch-release if an unreproducible issue is occurring in an environment. But if you can anticipate those kind of errors and what fine-grained information you require, maybe you would use this.

As always be aware of the cost of logging (both disk-space and how sometimes the more you log, the more it can obscure real errors)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.