[slf4j-dev] Trace and/or Ignore.
Endre Stølsvik
Endre at Stolsvik.com
Wed Jun 29 13:12:13 CEST 2005
On Tue, 28 Jun 2005, Randall J. Parr wrote:
| Niclas Hedhman wrote:
|
| > I have stayed out of the trace() discussion, mostly since "trace" indicates
| > something related to java.lang.Runtime.traceMethodCalls(). If it is just a
| > "finer" debug(), then another name, such as verbose, is more suitable.
| > However, verbose() is not a verb, but an adjective/adverb and should not be
| > used as method name. OTOH, warning and error is suffering from the same
| > problem, so I guess it is a moot point. ;o)
| > But is it apparent that debug() is level in between of warning() and
| > verbose()?? My natural reaction is that verbose() is part of the production
| > code, but debug() is only a development tool.
| >
| >
|
| To my mind it goes more like "info", "verbose", "debug", "trace" (aka
| "debuggier" :) )
I'd just like to comment on this topic, as trace is (or rather would be)
my favourite log-level ever. It has kinda become "a hot topic" with lots
of arguments.
The main problem with debug is that it is the only "development-level"
available in log4j, and (thus) also in slf4j.
One should have (at least) one more, and this is in my head obviously
"trace". This is acknowledged in most other logging packages, where a
level above debug usually is provided. Notable examples: apache commons
logging. JBoss have actually extended log4j with the "XLevel" log4j
example that is TRACE. Java.util.logging has -three- debug levels (fine,
finer, finest). Check out for yourselves.
But whatever, as long as there is inserted more than one code and
debugging level, I'd be happy no matter what they were called.
Debug will give you contextual information about what's happening.
However, trace goes far deeper, giving "bit-by-bit" information about the
code being executed, for example "form-element had value [5], validated
against [Integer validator]: [true]". It is obvious that this will clutter
the debug info too much if it were all over.
So, if you're about to really dive into some code that is buggy, turn on
debug for all areas that lie somwhat adjacent to the code (to get the
context), and then turn on trace for the code you want to examine. If you
need more info from the context, then turn on trace on some or all of
those parts too.
When I code on some project, I'd like all elements of the application to
stay in debug-mode, to get good context about the processing when adding
or changing features. But I can't do that since debug is also cluttered
with lots of too-verbose tracing stuff that doesn't really give anything
except when you really need it - when you want to "trace" the application,
or a specific part of it.
When one goes into production, the threshold is set to info, and one
just get "informational messages" about "user added" and "contract
changed" or whatever..
(fatal,) error, warn (, notice) and info are all "production levels". I
don't think anyone disagrees there. That leaves just one level for
actually coding and debugging the code, which is a really important reason
for logging. One level is just way to little. And why, really, has
production three levels (in slf4j), while the code and debug phase only
have the -one-?
This has, as probably everybody knows, been discussed at the log4j lists
at length _many_ times: _lots_ of users wants it, while some developers
refuse to add it. It was at some point, however, decided that it should
actually be added with the 1.3 release.
There once was a wiki page that tried to list the pros and cons of the
trace level being added to log4j.
This was located here:
http://nagoya.apache.org/wiki/apachewiki.cgi?Log4JProjectPages/TraceDebate
Sadly, that wiki is shut down, and for some reason, the new wiki's log4j
pages lack the one "TraceDebate" page. WayBackMachine wasn't of any help
either, as robots.txt of that old wiki apparently states that the pages
shouldn't be indexed.
Do a Google for "trace debug logging"..
PS: I feel that "verbose" doesn't have a qualifier. Is it "more verbose
information" (verboseInfo(..)) or "more verbose debugging"
(verboseDebug(..)) that is meant? Therefore some totally different word
would be better, and I favor "trace", rather obviously.
Endre.
More information about the slf4j-dev
mailing list