On 19/08/2025 10:34, Rémy Maucherat wrote:
On Tue, Aug 19, 2025 at 9:02 AM Mark Thomas <ma...@apache.org> wrote:
All,
I stumbled across quite few instances of log messages like this while I
was looking at something for $dayjob:
log.error(sm.getString("naming.bindFailed", e));
It would be lot more useful with the stack trace so I think that really
should be:
log.error(sm.getString("naming.bindFailed"), e);
Unless there are objections, I am going to change any log message with a
level of warning or greater that currently includes e, e.toString(),
e.getMessage() etc in the log message and doesn't log the full stack
trace to log the stack trace. I'll likely remove the exception from the
log message as well to avoid duplicating the text in the logs.
INFO level and is a little different. Those need looking at on a case by
case basis as I can imagine there are some cases where logging the full
stack trace is not necessary.
Sometimes the exception message is more than enough though. I think
the whole thing could be case by case.
I've just committed the changes for error level. Happy to discuss any
you think are unnecessary.
It was a bit of a mixed bag. There were a few where something more
useful than the exception message could be included in the log message
(like the container or the resource where naming failed), some were just
reducing duplication and one wrong log level.
The full stack trace might not be necessary but for error level issues
they don't happen that often and better to have the stack trace than
not. I've occasionally been in the position where I've had a log message
without a stack trace and really wished I'd had the stack trace too but
I've never thought "I wish I didn't have this stack trace".
And sometimes the root cause is helpful.
My expectation is that warning will be similar but info will be where
there are likely to be more cases where the stack trace makes less sense.
This is one of those areas where - once you start poking around you find
all sorts of things you want to tidy up.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org