A problem with logging libraries, is that even if I only use the app without needing *any* logging, I still have to include the jar of the logging library. And as small as it may be, it's still something I'd like to not distribute.


Then the problem of the logging library. Some want Jakarta Commons Logging, some JDK1.4 logging, some their system. Mind me, I understand that it's easy to make log4j output to their logging system, but it seems that some are really stuck to having to use their system throughout.

Finally, there is the speed issue. As fast as an if.isDebugEnabled() may be, we have seen that some places need a logging statement in a "close loop", and this makes performance degrade.

Ok, so what does all this mean?

It seems that there are three aspects:

1 - jar  dependency
2 - runtime removal of debug statements
3 - library dependency


jar dependency -------------------------- IE: I need to add a jar to my distro.

Possible solution: have the code use a class that is in the JDK already, and add there a method to attach a logging library to it.

Sample: a class that needs to log implements java.util.Observable
        a logger attaches to it as a java.util.Observer



 runtime removal of debug statements
------------------------------------------------------------
IE: I need to not include all the logging statements in my code

Possible solution: have the class files be preprocessed to remove all logging statements.

Sample: the class files are preprocessed by BCEL to remove these method calls


library dependency and runtime removal of debug statements ------------------------------------------------------------- IE: I need that logging library, and can't use mine

Possible solution + Sample: This is a bit more elaborate and solves in one go also the previous issue. Instead of adding the log statement, we insert in the code a special comment, that a preprocessor then can convert to use the logging library we prefer.

//[log] "Here is my log",exp,data,etc

This needs a recompile of course. So another possibility would be to code against a common API (log4j for instance) and make the conversion possible also without a recompile.

In this way, if I get a jar that has log4j as a dependency, and I don't want to log at all, or use my library, I could run it through the tool and have it transparently use my logging or none at all.

Comments?

--
Nicola Ken Barozzi                   [EMAIL PROTECTED]
            - verba volant, scripta manent -
   (discussions get forgotten, just code remains)
---------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to