Log4j Problem with Multiple Application

Discussion in 'Java' started by the.cagatay@gmail.com, Jan 17, 2005.

  1. Guest

    Hi,

    I have 5 different java applications(one has main method, others are
    threads) which uses log4j for logging purpose. The mechanism which is
    used for to run the programs, is
    A manager application starts the other applications. Each application
    has its own log4j configuration file with different names.
    I put root logger descreption for every file of the applications.
    The manager does not have logger.
    //////////////////////////////////////////////////////////////////
    <root>
    <priority value="DEBUG" />
    <appender-ref ref="App1Appender" />
    </root>

    <root>
    <priority value="DEBUG" />
    <appender-ref ref="App2Appender" />
    </root>

    <root>
    <priority value="DEBUG" />
    <appender-ref ref="App3Appender" />
    </root>

    <root>
    <priority value="DEBUG" />
    <appender-ref ref="App4Appender" />
    </root>
    //////////////////////////////////////////////////////////////////

    But When I did this, App1 and App2 applications did not log. I try to
    remove root logger from some of the files that only one file will have
    root logger description. At this point I get the error
    //////////////////////////////////////////////////////////////////
    log4j: No appenders could be found for category (some.category.name).
    log4j: Please initialize the log4j system properly.
    //////////////////////////////////////////////////////////////////
    I know I must declare root loger to solve this problem but when I put
    the root logger declaration to every file, some of the loggers do not
    log.

    In summary, I have 5 applications which have different log4j xml
    configuration file. And I want each of them to be configured according
    to the given file and logs correctly.
    Could you suggest something to solve this problem.
    Thanks :)
     
    , Jan 17, 2005
    #1
    1. Advertising

  2. Bob Kranson Guest

    I recall theres a default log4j.properties configuration in the log4j
    archive. You might want to look into that or use some of the command line
    options of log4j to initialize your applications. Sounds like your
    applications are properly isolated but maybe the classloader of the given
    application server is losing track of which root it read last; or possible
    using the included log4j default settings. Surely I read a 'comprehensive'
    log4j settings post out on the 'net. Maybe just make a category for each
    application to have more granular control in the long run....

    HTH
    Bob Kranson

    <> wrote in message
    news:...
    > Hi,
    >
    > I have 5 different java applications(one has main method, others are
    > threads) which uses log4j for logging purpose. The mechanism which is
    > used for to run the programs, is
    > A manager application starts the other applications. Each application
    > has its own log4j configuration file with different names.
    > I put root logger descreption for every file of the applications.
    > The manager does not have logger.
    > //////////////////////////////////////////////////////////////////
    > <root>
    > <priority value="DEBUG" />
    > <appender-ref ref="App1Appender" />
    > </root>
    >
    > <root>
    > <priority value="DEBUG" />
    > <appender-ref ref="App2Appender" />
    > </root>
    >
    > <root>
    > <priority value="DEBUG" />
    > <appender-ref ref="App3Appender" />
    > </root>
    >
    > <root>
    > <priority value="DEBUG" />
    > <appender-ref ref="App4Appender" />
    > </root>
    > //////////////////////////////////////////////////////////////////
    >
    > But When I did this, App1 and App2 applications did not log. I try to
    > remove root logger from some of the files that only one file will have
    > root logger description. At this point I get the error
    > //////////////////////////////////////////////////////////////////
    > log4j: No appenders could be found for category (some.category.name).
    > log4j: Please initialize the log4j system properly.
    > //////////////////////////////////////////////////////////////////
    > I know I must declare root loger to solve this problem but when I put
    > the root logger declaration to every file, some of the loggers do not
    > log.
    >
    > In summary, I have 5 applications which have different log4j xml
    > configuration file. And I want each of them to be configured according
    > to the given file and logs correctly.
    > Could you suggest something to solve this problem.
    > Thanks :)
    >
     
    Bob Kranson, Jan 18, 2005
    #2
    1. Advertising

  3. Guest

    This log4j.xml file sets the root log level to error and sets the log
    level for
    com.something to debug :

    <?xml version="1.0"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

    <log4j:configuration>

    <appender name="FileLog" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L -
    %m%n"/>
    </layout>
    </appender>

    <category name="com.something">
    <priority value="debug" />
    </category>

    <root>
    <priority value ="error" />
    <appender-ref ref="FileLog"/>
    </root>

    </log4j:configuration>
     
    , Jan 20, 2005
    #3
  4. imrantariq

    Joined:
    Jun 17, 2011
    Messages:
    2
    Hi

    Did you got success for this :

     
    imrantariq, Jun 17, 2011
    #4
  5. imrantariq

    Joined:
    Jun 17, 2011
    Messages:
    2
    Different log4j xml

    Did you got any success for it?

    I have 5 applications which have different log4j xml
    configuration file. And I want each of them to be configured according
    to the given file and logs correctly.
    Could you suggest something to solve this problem.
     
    imrantariq, Jun 17, 2011
    #5
    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. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,851
    Alexandra Stehman
    Jan 19, 2004
  2. Alex Hunsley
    Replies:
    2
    Views:
    13,075
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  3. Rodolfo
    Replies:
    0
    Views:
    983
    Rodolfo
    Jul 12, 2004
  4. joes
    Replies:
    1
    Views:
    2,282
  5. Gianni Galore
    Replies:
    0
    Views:
    1,316
    Gianni Galore
    Sep 8, 2010
Loading...

Share This Page