Welcome

What is Just4log ?

Just4Log is a library to enhance dynamically the performance of various logging systems inside a java application. Dynamically because the sourcecode in java is not modified but rather the optimization occurs on the compiled ByteCode files.

What logging systems are supported ?

(currently)

New feature: Automatic inclusion of enter and exit log statments in every method.

Starting with version 0.4, Just4log now supports the automatic inclusion of "enter" and "exit" log statment in every method.

Where is the trick ?

I will transpose in the Java language what Just4log really does at the bytecode level. Take that line of code:

for(int i=0; i<500000; i++) {
    logger.debug(" remember this is a problem with this: " 
                 + someLongTaskToExecute());
    normalCodeToExecute();
}
     

This is a typical case where there is a huge loss of performance due to logging, whether or not you have deactivated the debug mode: The compiled code will evaluate someLongTaskToExecute() before knowing if it really needs to. ( Java evaluates the arguments first, and then passes them to the considered method, This is called the "hidden cost of parameter construction." by Ceki Gülcü, the creator of Log4j.)

One common way to alleviate this problem would be:

for(int i=0; i<500000; i++) {
    if (logger.isDebugEnabled()) {
         logger.debug(" remember this is a problem with this: " 
                      + someLongTaskToExecute());
    }
    normalCodeToExecute();
}
     

I don't think this is satisfying because Logging/comments should definitely not obfuscate the rest of the code (even if considered as integral parts of the code). I didn't want to use a preprocessor. ( Remember: Preprocessors are not Java) So I decided a postprocessor would do the trick, thus was born Just4Log. Just4log simply adds a isDebugEnabled() if-fork before any debug() or other log methods at the compiled bytecode level. It preserves the clarity of your sourcecode while optimizing its performances.

How to use it ?

Just4Log offers various ways to optimize your bytecode.

  • A ant task offers integration in ant scripts. It is very simple and fast ( compared with java compilation, so there is no reason not to use it.)
  • A classloader implementation allows Just-In-Time optimization.(To be implemented)
  • A command line program allows optimization from normal scripts.(To be implemented)
  • Access via a GUI. (To be implemented)

Just4Log can work on two different kind of files:

  • Standard Java Class files. (description)
  • Zipfiles with Classfiles inside. This includes Jarfiles, Ear, War, etc...

How much does it cost ?

Just4log is distributed under the Apache license and thus is free, and open sourced. This means that you have access to the source code, modify it and redistribute it freely. If you want you can also make your contribution public... Please contact me. Beware that it comes with NO WARRANTY of reliability, merchantability and so on. If it turns out it wasted your software, don't complain... Please backup your code before using Just4log. However you can submit a bug request. I'll try to maintain this software as much as possible.

$Id: index.xml,v 1.10 2003/07/24 00:27:37 lbruand Exp $Copyright 2003 Lucas Bruand