I am using Log4J for logging in my current project with too many logging statements. I
wrap every logging statements with the isDebugEnabled(), isWarnEnabled(), etc. During
production , the logging level will be set to very minimum, and only critical errors will
be logged. But however, the boolean comparison statements (whether or not to log) will
be executed, which we feel will have a performance impact.
You're probably wrong.
http://jakarta.apache.org/log4j/docs/index.html
Their benchmark is 5nanoseconds to do that method call to determine if a particular logging level is enabled. If you're THAT concerned about 5ns, your program probably has such hard performance requirements that you designed first around performance to begin with, no?
I would like to know if it is a good idea to pre-process the java code to remove all the
logging statements and then create the binary?? or to begin with, limit the number of
logging statements during the development process itself?? If pre-processing the source
code to find and remove logging statements.. is a better option, then can some one point
me to a good java pre processor?
Don't bother. For this, you can rely on public static final boolean member variables.
Basically, if you compile with any type of optimization on, any call that is like this:
if(false) {
}
will be optimized away entirely (i.e. the bytecodes won't even appear in the .class file at all). That also flows through variables:
public class Debug {
public static final boolean DEBUG_LEVEL = false;
}
public class Foobar {
public void doStuff() {
if(Debug.DEBUG_LEVEL) {
// This can never happen and won't
// be in the bytecodes.
}
}
}
So if you care THAT much about 5ns per call, do it this way (through compilation) and let the java compiler do the work for you. For this, even if you decide to pre-process, you don't have to pre-process.
But do you really care that much about 5ns? Are you SURE you care that much about 5ns?
Kirk Wylie M7 Corporation
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

