Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log levels: Would you consider DEBUG finer than TRACE?

My question originates from this question, where one of the comments suggests that a DEBUG log level is finer grained than TRACE. Looking at what TRACE and DEBUG means in .NET, this seems to make sense, since, by definition, DEBUG (as a concept) is never seen in production. This is probably why they are'nt used as an event type in the Enterprise Library. On the other hand, all other implementations that I know of (log4net, nlog, common.logging) has TRACE as a finer level than DEBUG. That is, an application running at DEBUG log level would not write TRACE logs.

We need to implement our own log framework and I was wondering if there are more people out there that thinks that DEBUG really should be the most "spammy" log level? Or would you consider this a mistake if our new framework should provide some easy-to-use familiarity to new developers etc?

Thanks.

like image 267
Werner Avatar asked Jun 25 '12 08:06

Werner


People also ask

Is trace greater than debug?

The TRACE log level captures all the details about the behavior of the application. It is mostly diagnostic and is more granular and finer than DEBUG log level. This log level is used in situations where you need to see what happened in your application or what happened in the third-party libraries used.

Is trace lower than debug?

Is trace higher than DEBUG? Ans. TRACE designates finer grained informational events than the DEBUG. TRACE is level lower than DEBUG.

What is debug logging level?

A debug level is a set of log levels for debug log categories, such as Database , Workflow , and Validation . A trace flag includes a debug level, a start time, an end time, and a log type. The log types are DEVELOPER_LOG , USER_DEBUG , and CLASS_TRACING .

What is the difference between debug and trace?

Trace works in both debug and logging mode, recording events as they occur in real-time. The main advantage of using trace over debugging is to do a performance analysis, which can't be accomplished on the debugging end.


2 Answers

I agree with TRACE being finer than DEBUG.

Example: If I used PostSharp to add automatic logging statements to each method call in my application, I'd want this code to be injected in the beginning of each method:

if (Log.IsTraceEnabled)
   Log.TraceFromat("Method {0} args {1}", method, string.Join(",", args));

That is, I interpret the level "TRACE" as helping me trace calls through the application, while DEBUG is writing information that help developers debug program behavior. Don't know if that makes sense?

like image 96
Anders Forsgren Avatar answered Sep 23 '22 22:09

Anders Forsgren


Bare in mind that log4net comes from the Java world, and NLog takes many of its ideas from log4net - so Trace and Debug will differ for those frameworks as they're not based on the .NET framework designer's world view of logging which is in the System.Diagnostics namespace.

I would suggest that Trace in .NET is synonymous with Debug in the .NET world, as you enable tracing (via the TRACE compiler directive or in the web.config) in order to show Debug information.

Obviously in NLog and Log4Net the severity of the information may be interpreted as slightly different, but both would end up being use for tracking a bug down, rather than a system error, so they have essentially the same meaning.

like image 39
Chris S Avatar answered Sep 25 '22 22:09

Chris S