Log levels: Would you consider DEBUG finer than TRACE?
Asked Answered
A

2

6

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.

Aldos answered 25/6, 2012 at 8:33 Comment(0)
D
4

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.

Deafen answered 25/6, 2012 at 9:11 Comment(2)
So if you were to implement your own logging framework, you'd only have one level (like Verbose in Entlib)?Aldos
@Aldos yes definitely! Information, Error, Warning just like .NET. The java-based extra levels make sense for business or safety critical high transaction systems, but for most people's needs are overkill.Deafen
A
6

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?

Achates answered 25/6, 2012 at 8:52 Comment(1)
Yes it makes sense. In fact most developers here sees the world like that. But that could be coincidence, and we don't want to come up with something that would be misunderstood by 8 of 10 developers :)Aldos
D
4

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.

Deafen answered 25/6, 2012 at 9:11 Comment(2)
So if you were to implement your own logging framework, you'd only have one level (like Verbose in Entlib)?Aldos
@Aldos yes definitely! Information, Error, Warning just like .NET. The java-based extra levels make sense for business or safety critical high transaction systems, but for most people's needs are overkill.Deafen

© 2022 - 2024 — McMap. All rights reserved.