log4j, tomcat and multiple webapps

Discussion in 'Java' started by PeterH, Sep 29, 2005.

  1. PeterH

    PeterH Guest

    Hi all,

    I have a number of different webapps deployed which are all logging to the
    same log file, depending on which one is started first and how the server
    is feeling at the time.

    The log4j.properties files start with a line of the format:

    log4j.logger.<package>.<class>=DEBUG, R

    In the matching classfile in the webapp, the logger is declared as:

    private static Log log = LogFactory.getLog(<class>.class);


    Where am I going wrong?
    PeterH, Sep 29, 2005
    #1
    1. Advertising

  2. PeterH wrote:
    > Hi all,
    >
    > I have a number of different webapps deployed which are all logging to the
    > same log file, depending on which one is started first and how the server
    > is feeling at the time.
    >
    > The log4j.properties files start with a line of the format:
    >
    > log4j.logger.<package>.<class>=DEBUG, R
    >
    > In the matching classfile in the webapp, the logger is declared as:
    >
    > private static Log log = LogFactory.getLog(<class>.class);
    >
    >
    > Where am I going wrong?


    The typical thing to do with log4j in a web container is to supply each
    web application with its own log4j.jar. The class loading rules for web
    applications imply that each web application will get its own version of
    the log4j classes, and so then will not share the static configuration
    information.

    HTH,
    Ray

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Oct 8, 2005
    #2
    1. Advertising

  3. PeterH

    Juha Laiho Guest

    Raymond DeCampo <> said:
    >PeterH wrote:
    >> I have a number of different webapps deployed which are all logging to the
    >> same log file, depending on which one is started first and how the server
    >> is feeling at the time.

    ....
    >The typical thing to do with log4j in a web container is to supply each
    >web application with its own log4j.jar. The class loading rules for web
    >applications imply that each web application will get its own version of
    >the log4j classes, and so then will not share the static configuration
    >information.


    The other possibility (to keep a single set of log4j classes shared among
    the applications) would be to use (write) a RepositorySelector to bridge
    between Tomcat and Log4j.
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)
    Juha Laiho, Oct 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rodolfo
    Replies:
    0
    Views:
    946
    Rodolfo
    Jul 12, 2004
  2. Martin Eberle
    Replies:
    2
    Views:
    814
  3. WD
    Replies:
    1
    Views:
    1,957
    Raymond DeCampo
    Aug 19, 2005
  4. unomystEz
    Replies:
    0
    Views:
    532
    unomystEz
    Nov 19, 2006
  5. bugbear
    Replies:
    0
    Views:
    627
    bugbear
    Jun 12, 2007
Loading...

Share This Page