[jsword-devel] Replacing log4j

Joe Walker joseph.walker at gmail.com
Sun Sep 19 15:03:42 MST 2004


The idea behind the wrapper was that it makes it easy to switch from
l4j to something else

Other advantages of log4j:
- comes with outputters for more things; unix syslog could be useful
to someone wanting to write a webapp for example and there are GUIs
that let you look at the output.
- i seem to remember that it was easier to configure for some complex
logging config files.

While these are not reasons to stay with log4j, they are perhaps
reasons to not burn the bridge back, and the Logger class is really
small.

Joe.

On Sun, 19 Sep 2004 17:47:23 -0400, DM Smith <dmsmith555 at yahoo.com> wrote:
> Well I have taken a look at replacing log4j with Java's logger. The goal
> is to make common as light as possible (wrt to dependencies on outside
> jars) so that other projects would not hesitate to use it.
> 
> It looked like it was a pretty simple change, but there is a snag. It
> does not properly report the location of the logging.
> 
> First let me describe how the two map to each other:
> Both have the same notion of getting a logger named via the class name:
> log4j is Logger.getLogger(Class clazz)
> java is Logger.getLogger(String classname)
> 
> Both have predefined levels in a Level class.
> log4j: FATAL,ERROR,WARN,INFO,DEBUG
> java: SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST
> and both have convienence functions for these methods. I see mapping
> them from left to right and not using FINER and FINEST.
> 
> Both have:
>     the same notion of inheritance of logging
>     the same notion of a root logger
>     the same notion of configuration by a properties file
>     the ability to set the global logging level
> 
> Differences:
> log4j allows for a Throwable to be passed into the convienence methods
> (e.g. log.warn("message", throwable) and it appends it to the message.)
> java requires the use of logger.log(Level.WARNING, "message", throwable)
> 
> log4j can be wrapped and produce class, method and line of the caller.
> Java's logger does not dig into the stack trace to determine the nearest
> match to the logger's class.
>     Solution: in the wrapper get the stack trace and figure out the
> calling class, method and line. Not very easy but can be done.
> 
> log4j writes to stdout, while java writes to stderr. This is
> configurable in log4j and I think in java. My opinion is that stderr is
> better as it is not buffered.
> 
> log4j has single line output, java has 2 line output. This is
> configurable in log4j and I think in java.
> 
> I am going to check in the change to .../common/util/Logger.java so you
> can see the differences. I handled the stack trace.
> 
> Given our use of log4j, I don't see any advantage of it over Java's logger.
> 
> My recommendation is to migrate to Java's logger directly and not
> wrapped (as opposed to solving the wrapping problem).
> 
> I'll be looking into configuring the logger to mimic the output of log4j.
> 
> _______________________________________________
> jsword-devel mailing list
> jsword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/jsword-devel
>


More information about the jsword-devel mailing list