In Log4J, Slf4J and a couple other logging frameworks in Java, you have two "developper" level for logging:
- DEBUG
- TRACE
I understand what DEBUG does, because the explanation is clear:
The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
But the TRACE level is not very specific about its use case:
The TRACE Level designates finer-grained informational events than the DEBUG
(Source: the log4J JavaDoc)
This does not tell me how or when to use TRACE. Interestingly, this is not a severity level defined in the syslog standard. Googling for the difference between TRACE and DEBUG only seem to return "use DEBUG, oh, and there is TRACE too". I couldn't find a specific use case for the TRACE level. The best I could find was this old wiki page debating the merit of the existence of the level.
This, as an architect, raises a lot of flags and questions in my head. If a young developer asked me to add TRACE to my architecture, I would bombard him with questions:
- What are some examples of information that should be logged with TRACE and not with DEBUG?
- What specific problem do I solve by logging that information?
- In those examples, what are the properties of the logged information that clearly discriminate between logging at the TRACE level rather than the DEBUG level?
- Why must that information go through the log infrastructure?
- What are the benefits of persisting that information in a logs journals rather than just using
System.out.println
? - Why is it better to use log for this rather than a debugger?
- What are the benefits of persisting that information in a logs journals rather than just using
- What would be a canonical example of logging at the TRACE level?
- What are the specific gains that have been made by logging at the TRACE level instead of DEBUG in the example?
- Why are those gains important?
- In reverse: What problems did I avoid by logging it at TRACE instead of DEBUG?
- How else could I solve those problems? Why is logging at the TRACE level better than those other solutions?
- Should TRACE level log statement be left in the production code? Why?
But given that it is present in most major framework, I am guessing it is useful for something? So... what is TRACE for, and what distinguishes it from DEBUG?