@hackage hslogger4j0.1.1

hslogger handlers for log4j's XMLLayout

  • Categories

    • License

      LicenseRef-LGPL

    • Maintainer

      bjorn.buckwalter@gmail.com

    • Versions

      • 0.2 Wed, 26 Nov 2008
      • 0.1.1 Fri, 19 Oct 2007

    Introduction

    Hslogger4j provides handlers for hslogger[1] (John Goerzen's Haskell logging library) that are compatible with log4j's XMLLayout. In particular log messages created by the handlers can be published directly to the GUI-based log viewer Chainsaw v2[2].

    The set of log levels in hslogger is richer than the basic set of log4j levels. Two sets of handlers are provided with hslogger4j, one which produces logs with hslogger's levels and one which "demotes" them to the basic log4j levels. If full hslogger levels are used some Java installation is necessary to make Chainsaw aware of them.

    Usage of the handlers in hslogger4j is analoguous to usage of the 'StreamHandler' and 'FileHandler' in 'System.Log.Handler.Simple'. The following handlers are provided:

    • log4jStreamHandler (hslogger levels)
    • log4jFileHandler (hslogger levels)
    • log4jStreamHandler' (log4j levels)
    • log4jFileHandler' (log4j levels)

    Installation

    Haskell

    Use the regular cabal process:

    runhaskell Setup.lhs configure runhaskell Setup.lhs build runhaskell Setup.lhs install

    Java

    This is only necessary if you want to use the hslogger levels.

    Add 'hslogger4j.jar' to your classpath. To use you will also need to have the jars 'log4j-1.3alpha-7.jar' and 'log4j-xml-1.3alpha-7.jar' that are distributed with Chainsaw on your classpath.

    (On Mac OS X I added all three jars to '~/Library/Java/Extensions'. It seems that it is not sufficient that Chainsaw already includes its jars in the classpath when launching -- perhaps the plugin classloader does not inherit Chainsaw's classpath. Adding the jars to '~/.chainsaw/plugins' wouldn't work either.)

    If for whatever reason you have to rebuild the hslogger4j jar just run 'ant'[3]. The new jar will be created in the 'dist/lib' directory.

    Usage

    Haskell

    In the IO monad:

    lh2 <- log4jFileHandler "log.xml" DEBUG updateGlobalLogger rootLoggerName (addHandler lh2)

    h <- connectTo "localhost" (PortNumber 4448) lh <- log4jStreamHandler h NOTICE updateGlobalLogger rootLoggerName (addHandler lh)

    Chainsaw

    If you are only using the basic log4j levels just use Chainsaw's regular facilities to browse logs or listen for log messages (XMLSocketReceiver).

    If you want to use the hslogger levels the easiest way to set up Chainsaw is to load the plugins in 'hslogger4j-plugins.xml' when launching Chainsaw. Two receivers will be defined, one that listens for logmessages and one for reading log files. Edit the properties of those receivers as needed (e.g. port, file name) and restart them.

    Copyrights and licenses

    The Haskell code is copyright John Goerzen and licensed under LGPL. The Java code is copyright of the Apache Software Foundation and licensed under the Apache License. See the source file headers for details.

    Bugs, patches and stuff

    Send to bjorn.buckwalter@gmail.com.

    References

    [1] http://software.complete.org/hslogger [2] http://logging.apache.org/chainsaw/ [3] http://ant.apache.org/