tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee <g...@edamame.stinky.com>
Subject [VOTE] On Logging
Date Fri, 23 Jun 2000 20:16:51 GMT

> To add to the wish list - timestamps as long and optional !! You can
> convert long to date in a postprocessor.
> ...
> Please make sure you have a way to turn timestamp off - or at least
> output it asa long, not as a formated date. Formating dates is one of
> the slowest operations, and a big hotspot.

Good points. Timestamps are already optional; you can set
timeStamp='no' in server.xml.  (I see Costin figured that out already :-)

Vote please:

Proposal 1: The default timestamp format to be msec-since-epoch, not
new Date().toString()

Proposal 2: Add a "timeStampFormat" property to server.xml/Logger,
which allows for locale-sensitive string date formatting

Possible values for timeStampFormat:
"" or null -- use msec-since-epoch
"FULL", "LONG", "MEDIUM", "SHORT" -- follows semantics of java.text.DateFormat
other string -- follows semantics of java.text.SimpleDateFormat (e.g. "yyyy-MM-dd hh:mm:ss")

(This may be overkill, so I'd just implement the simple case to start
with, unless I happen to have just had a cup of coffee)


> Since you work on logger, is any reason to have the log level in
> logger and also in the component ?
> 
> Most components will do a
> 
> if( debug > internal_level ) log("msg" + arg + arg);
> 
> It is important to do that in order to avoid evaluation of string
> concat if no log is needed, and to set log level for components - you
> want to debug the mapper, no need to see all the messages.  I find
> confusing to have both a level in the component and a global one.

Yeah, that's the one reason it's nice to have macros.  (Well, one of a
few reasons :-)

I agree that each component having its own log level is confusing, but
that it may be useful when trying to debug a particular component (as
you mentioned).  However, that can be worked around by just setting
the global level high, then grepping the log for the name of the
component you're interested in.  With LogHelper each message is tagged
with the name of its source, so this is easy.  So I don't think the
extra complexity of each component having its own level is warranted.

Another problem is that the concept of "level" seems to have different
semantics in different parts of the program; at some points people
treat it as an int (if (level > 9)), at others, like an enum
(Logger.INFORMATION).

I think the solution is something like you said Sam Ruby proposed:
syntax like

 log("Trying to set {0} to {1}", name, value);

That way no string formatting would take place unless the logger's
level is high enough (after a few method calls, which isn't that big a
performance deal in case it's below threshold).

Vote please:

Proposal 3: Remove concept of debug level from each component; just
make each logger sensitive to the debug level, and only print messages
with a low enough level.

Proposal 4: Set the interface of LogHelper (and probably Logger) to:

 public void log(int level, String message, Object[] params, Throwable exception)

and many permutations of above, like

 public void log(String message, Object[] params)
 public void log(String message, Object param)
 public void log(String message, Object param1, Object param2, Throwable e)

where the default level is "Logger.INFORMATION"

This would allow usage like 
 loghelper.log("My {0} has {1}", "dog", fleas");
or
 loghelper.log("The {0} {1} {2} jumped over the {3} {4}", 
		    new Object[] { adjective1, adjective2, noun1, "lazy", noun2));


The key here is to make it easy for programmers to insert log
messages.

Along those lines, are there any strong feelings for or against
standardizing server log messages as English?  The arguments for this
are, it keeps strings right in the code, so it's easier to program and
maintain, and since no end-users will see the logs, just programmers,
then the need for localization is less compelling.  Also, it would
allow standard log parsing tools or scripts to work in any country
without needing to be localized.


> >   Does anyone actually use non-custom logs?

Anyone? Meaning the <tc_log>message</tc_log> format...



-- 
Alex Chaffee                       mailto:alex@jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

Mime
View raw message