Switching default log4j threshold

Heiko W.Rupp hrupp at redhat.com
Thu Jan 21 08:47:27 UTC 2010


Am 21.01.2010 um 07:32 schrieb Joseph Marques:

> daily development, but we should leave it at INFO for the prod builds so 
> as not to create hundreds of megs of logs at client sights, which would 
> (considering the default log file retention policy) overwrite any 
> meaningful data that would have been useful attachments for customer 
> support cases.

Also just remember two things:

- logging is expensive and can slow down the server - if not by the logging itself (see below), then
 when logfiles are rotated. I did once in our test suite increase the logfile size from the default (1M ?)
 to 50M (I may also have bumped to debug/trace logging and sql logging) and the tests were running 
 a magnitude faster just because the it was no longer rotating the logfile every few seconds.

- please guard your log statements

  if (log.isDebugEnabled() 
        log.debug(expression)

or even

  Contructor() {
     debugEnabled = log.isDebugEnabled();
  }


  private foo() {
     if (debugEnabled)
           log.debug(expression)


The reason for this is, that expression is only evaluated when the threshold is low
enough. This will
  - save time for evaluating expression
  - save object creations and later GC
  - increase the possibility for code to stay in the cpu cache
 
And if the threshold is INFO, the expression will be evaluated without the guard
just to be thrown away by the logging subsystem, which is an expensive no-op.

  Heiko



More information about the rhq-devel mailing list