Question

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.

Était-ce utile?

La solution

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.

Autres conseils

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?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top