Skip to main content

Logger frameworks

Let's have a look round in the world of logging.
There is a glorious article in the Wikipedia about fundamental concepts of logging.

Two (or rather three) competitors are log4j, java logging API == java.util.logging == JUL == JSR47 and Java Commons Logging == JCL. The latter is not a real logging framework, just an adapter which quests for the available framework in runtime and uses it. It can be helpful when we don't want to wrap some modul to log4j, JUL or anything, however, it has disadvantages regarding efficiency and functionality. See this article about it: Think again before adopting the commons-logging API

Here is an opinion about differences between log4j and JUL. I've read it a long time ago and deeply agree with it with the supplement, that because of the continuous inconveniences I hate Java Logging API.

(The author of the former article, Ceki Gülcü is the founder of log4j. He has a blog where he writes engaging things. For an example, mentions presentation of Linus Torvalds about GIT vs SVN. Well, I also didn't like that style not to say about this.)

Nowadays it seems that he (Ceki Gülcü) walks differents ways from Apache group, because he is working on the possible posteriors of log4j and JCL, namely LogBack and SLF4J. (Wikipedia article doesn't mentions these.) Theoretically, SLF4J will have log4j support. I don't know how much will be SLF4J efficient but I guess they started to implement a new framework because they wanted to make something better.

log4j exists since Java 1.1, JUL was invented in 1.4. By exploring homepage of log4j it turns out soon that there's no version which exploits advantages of Java 5.0. Log4j 2.0 would have been the one which fulfils this task, but there are not too much (any) visible activity in this subject.

However, LogBack and SLF4J are going to be in a useable shape soon. LogBack has version 0.9.X nowadays. On our Hungarian forum there was a flame about logBack and using isDebugEnabled. First important consequence was for me, that people do log in many different styles and it depends on the developed application. Somebody can use toString often, somebody doesn't have this possibility. Secondly, isDebugEnabled condition can't be dropped out in every cases, just when there are no expressions in the parameter list. (For sample, explicit high-cost function calls.) By the way, using varargs instead of String evaluation can be rather beneficial during logging.

Which one would I choose? In conservative software modules, when embedding environment may not be log4j-based I would choose JCL. Otherwise I would use log4j. At newly started projects I would use LogBack or SLF4J, although I would get a line if there are existing appenders which I should use. Regarding log4j, (as it is an old professional in the scene) there are a lot of appenders.

(This was a translation again. See original here in Hungarian.)

Comments

Popular posts from this blog

Client's transaction aborted

I've met the above error message using a Wicket 1.2 / EJB3 intranet application under Glassfish v2 . Here is the more particular head of the stack trace: javax.ejb.TransactionRolledbackLocalException: Client's transaction aborted at com.sun.ejb.containers.BaseContainer.useClientTx(BaseContainer.java:3394) at com.sun.ejb.containers.BaseContainer.preInvokeTx(BaseContainer.java:3274) at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1244) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:195) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:127) This exception raised on the integration server sometimes, randomly, for simple page fetch operations. After pressing reload on the browser, the operation was usually successful. I couldn't reproduce the failure on the local machine where I regularly restart the app server and

jxl.log

In an intranet production environment we have running a Glassfish v2 appserver with several J2EE applications which all use JexcelApi , a.k.a JXL, which is an open source library for accessing, generating or manipulating Microsoft Excel documents. We use version 2.6.3 of JXL because it's the recent one in the Maven repository which we use, however, at the official JXL site there are newer versions. Additionally we have log4j and Java Commons Logging (JCL), ignoring Glassfish's JSR-47 Java Util Logging (JUL) facility. Application #1 uses purely log4j and gets its log4j.xml config from a custom location. Application #2 runs Java Commons Logging with no explicite configuration file given, so JCL uses the default JUL facility of the appserver. Application #1 had been running for a long time without problems but when we installed #2 we realized that a jxl.log file had been created in the glassfish/domain/domain1/config directory and it's rapidly growing. As it happens, we

Brillien

There were three presentation as usual at the 14th Java User Meeting at Budapest yesterday, but this time I'll write only about the first one. Imre Fazekas had been invited from Debrecen to make a presentation about Brillien , their Java enterprise platform. It's an alternative way of modeling and implementing business logic in place of Java Enterprise (J2EE) Technology. It uses invasive programming model which means we have to extend classes from Brillien superclasses and we may use annotations. The whole system based on asynchronous XMPP communication and a set-context-flow concept. It's something like an application server, but uses a more logical and set-based approach. As the presenter said, it has very good speed and performance characteristics. Currently there are no IDE or other tools for editing models because this is a very young project, however a Maven plugin and a Maven archetype is accessible on the homepage. A very good introduction and tutorial can be also