I have done something and can see where it might be generalized to help other
users of log4j. Has this issue already been discussed or dealt with in some
other way?
I found a bunch of these in a large legacy application:
log.debug("the object "+obj+" is something something blah blah blah");
The problem, of course, is that regardless of whether the Level will lead to
the statement being logged out, the obj's toString() method gets called. This
can lead, at times, to quite a bit of work. And that works gets thrown away
almost all of the time. So I have written a class that I send all of my log
statements through. That class has methods:
static void info(Logger log, Object… objs);
static void debug(Logger log, Object… objs);
static void error(Logger log, Object… objs);
In the info() method, the Level is checked. If it is going to print, then the
obis are iterated through. And for some kinds of objects we call toString but
some objects are handled in a smarter manner.
It seems to me that the methods in the LoggingEvent class could have the
"Object message" parameter changed to "Object… messageObjects".
Am I the only one who has seen the mistake shown above? I suspect not. If the
LoggerEvent class did the right thing with the messageObjects array, such as
only writing out hashes of certain objects, it seems to me that this would help
a lot of people and, if anyone wanted to customize the behavior, it would be
clear how to do so.
Yes? No? Any other suggestions or ideas?
cheers - ray
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]