I am only a peripheral Log4J User, however my peers recently advised
that all our
logging should be written like:
if(logger.isDebugEnabled()) {
logger.debug("Entry number: " + i + " is " +
String.valueOf(entry[i])); }
Personally, I think that is an absolute abomination, and a major failure
of the logging framework / Java combination.
That amount of extraneous 'noise', required typing (probably), and usage
of screen real-estate in the source code will clearly discourage regular
usage of detailed logging output.
When most methods should be a handful of lines, and most methods should
be
able to log at the most detailed log level, that amount of overhead is
really annoying.
Completely unacceptable in my books.
It should be simple, succent and efficient.
For gods sake, this was all figured out in the 70's with the C
pre-processor.
OK, not really Log4J's problem - More a Java limitation...
And yes, I have been pointed to Aspect compiler solutions (Almost
passable).
I'm just dissappointed that the solution here is not very elegant, given
the maturity of Java.
Sigh, history so often repeats itself...
-----Original Message-----
From: Lilianne E. Blaze [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 11 June 2008 2:05 PM
To: Log4J Users List
Subject: Re: log4j best practises
Hello,
Quite an useful text.
One thing I can't agree with:
"I recommend skipping the generalization if possible. You will have more
control over log4j if you use it directly. You cannot execute log4j's
PropertyConfigurator.configure( "/etc/log4j.properties" ) at your
leisure if using "commons-logging"."
You can use JCL everywhere except the config part where you use Log4j
directly. If you're forced to change logging api you only have to change
one or two files instead of the whole project.
Speaking of best practices - is it really better to use things like
logger.debug("The entry is {}.", entry);
instead of
if(logger.isDebugEnabled()) {
logger.debug("Entry number: " + i + " is " +
String.valueOf(entry[i])); }
Sure the first one is shorter, but isn't the second one faster?
Greetings, Lilianne E. Balze
Julius Davies wrote:
> Here's a page of what I consider log4j best practises:
>
> http://juliusdavies.ca/logging.html
>
>
> Any comments are very welcome!
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]