Ole Ersoy wrote:
No, the call log.info(SOMETHING) will need to calculae something,
before it really calls the error method of the logger, which then
immediately might notice, that the configured log level doesn't allow
handling an info message.
Now SOMETHING is quite often not a simple string, but e.g. a localised
message, an exception text, a string concatenation containing some
variable data etc. Java will first calculate SOMETHING, before it
jumps into the logger method. If you have a lot of debug log
statements, which get called during every request, it will have a
noticeable impact on performnce.
OK - I get it ... hopefully :-). We want to do something like:
if (log.isDebugEnabled())
{
//Calculate SOMETHING - Very expensive
String SOMETHING = SOMETHINGA + SOMETHINGELSE;
log.debug(SOMETHING);
}
Close, because of the "if", we would usually simply do
if (log.isDebugEnabled())
{
//Calculate something very expensive
log.debug(SOMETHINGA + SOMETHINGELSE);
}
but it has nearly the same meaning and behaviour as your more explicit
example. The concatenation will be done before actually calling the
debug method.
So if we are only interested in SEVERE messages, then it seems like it
would be a good thing to set all of the Tomcat loggers to only log
severe messages? Is there a simple way to do that? I would think that
the Tomcat loggers get their log level from a root logger, and that if I
set the log level on that logger, then it automatically sets it on all
the other loggers, unless I directly override the logging level as with
Facility specific properties?
Should be
.level = SEVERE
But even with the default config, Tomcat doesn't log much. So keeping
the default usually is safer, because you actually don't know, how
individual developers decide between using error and severe. So at least
error should be logged to. If there is a sub component, that logs to
much, you should restrict this component and not the whole server.
Warnings are not frequent enough to justify the if statement.
So I assume the logic is that most running instances will be interested
in warnings, hence just skip the if?
Exactly. For log.warn(), developers don't use the isWarnEnabled() idiom.
But: the loggers with the strange names
...Catalina...localhost...mycontext are generated for each context,
and can be used by the webapp developer as part of the servlet API
(the context logger). So the webapp producer might have some
documentation, what kind of log messages he creates at which level.
OK - so /mywebapp could grab the Logger for the /manager context and
No it would grab the logger for the context, which will automatically be
the one for [/mywebapp] and not [/manager]. It can't log to the logger
of another context. Look at javax.servlet.ServletContext.log().
make logging calls on it, which assuming the default configuration would
end up in the manager prefixed log?
So now you should be able to write an improved version of the logging
documentation page ;)
Regards,
Rainer
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]