Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed0.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Jim Gibson Newsgroups: comp.lang.java.programmer Subject: Re: analysis of java application logs Date: Tue, 24 May 2011 11:00:09 -0700 Lines: 51 Message-ID: <240520111100099912%jimsgibson@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: individual.net noA6iRb2DOeLfpbHhoqQzANEOhBhfVMNk1GC4VB7T8Nwc/66xH X-Orig-Path: jimsgibson Cancel-Lock: sha1:5cycMtINzKgM+QxTISxWt4BHlDA= User-Agent: Thoth/1.8.5 (OS X) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4544 In article , Lew wrote: > Martin Gregorie wrote: > > Lew wrote: > >> Martin Gregorie wrote: > >>> Fair point. However, my usual debugging statement takes the form: > >>> > >>> if (debug> 0) > >>> debugger.trace(result + " = method(" + arg + ")"); > >>> > >>> Ugly, I know, but quite efficient, since when debugging is off even the > >>> cost of the method call cost is. I use an integer to control debugging > >>> rather than a boolean so I can control its volume: "java Application > >>> -dd" would be expected to provide more detailed debugging output than > >>> "java Application -d" > > >> What's wrong with > >> > >> if ( logger.isDebugEnabled() ) ... > >> > >> or > >> > >> if ( logger.getLevel().isGreaterOrEqual( Logger.DEBUG )) ... > >> ? > > > Not a lot, though that does involve method call overheads that you may > > not want in a tight loop. > > Seems like it's a simple equality test that would be HotSpotted away. My understanding of the log4j and java.util.Logger classes is that each logger exists within a hierarchy of classes, and that to determine whether or not a specific logger call will produce output, the library must test each level, starting at the specific class and traversing upwards in the hierarchy. So using a static variable as below to enable and disable logging output can save some execution time: static final boolean debug = false; if( debug ) { logger.debug(...); } Whether or not that is significant, depends upon the situation, of course. -- Jim Gibson