Tomcat Cannot Find log4j.properties file

Discussion in 'Java' started by John, Jul 19, 2004.

  1. John

    John Guest

    I am trying to install log4j into an existing web app. However, when I
    debug it seem that the ligger is using ConsoleAppender instead of
    RollingFileAppender.

    I am guessing that it is not finding the log4j.properties file.

    Any ideas?

    -----
    log4j.properties:

    # Sample properties to initialize log4j
    log4j.rootCategory=debug, R
    log4j.appender.R=org.apache.log4j.RollingFileAppender
    log4j.appender.R.File=./regreporting.log
    log4j.appender.R.MaxFileSize=100KB
    log4j.appender.R.MaxBackupIndex=2
    log4j.appender.R.layout=org.apache.log4j.PatternLayout
    log4j.appender.R.layout.ConversionPattern=%p %d %c - %m%n


    ---
    java file:

    import org.apache.log4j.Logger;

    public class RegRptTaskSpecInitAction extends Action {

    private static Logger logger =
    Logger.getLogger(RegRptTaskSpecInitAction.class.getName());

    ......
    public void getValue(){
    logger.debug("*****TEST THIS TODAY");
    }
    }
    John, Jul 19, 2004
    #1
    1. Advertising

  2. John

    Juha Laiho Guest

    (John) said:
    >I am trying to install log4j into an existing web app. However, when I
    >debug it seem that the ligger is using ConsoleAppender instead of
    >RollingFileAppender.
    >
    >I am guessing that it is not finding the log4j.properties file.


    If you can, restart Tomcat so that the system property log4j.debug is set
    to true. This will cause log4j to emit internal logging information into
    Tomcats logs.
    --
    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, Jul 20, 2004
    #2
    1. Advertising

  3. (John) wrote in news:27212259.0407190733.a1a73f3
    @posting.google.com:

    > I am trying to install log4j into an existing web app. However, when I
    > debug it seem that the ligger is using ConsoleAppender instead of
    > RollingFileAppender.
    >
    > I am guessing that it is not finding the log4j.properties file.


    Sorry if this is too stupid, but where have you put the log4j.properties?

    The most common solution is in <your-app>/WEB-INF/classes/

    The documentation state that it is easy and works, and
    I confirm this statement.

    Other choices are possible, but less common.

    Moreover, you miss the log4.rootLogger:

    > # Sample properties to initialize log4j
    > log4j.rootCategory=debug, R

    should be, AFAIK,

    log4j.rootLogger=DEBUG, R

    (maybe yous is good, but i can swear only about mine!)

    My two cents...

    --
    Andrea Spinelli - IT&T srl
    Via Sigismondi, 40 - 24018 Villa d'Alme' (BG)
    tel: +39+035636029 - fax: +39+035638129
    http://www.imteam.it/
    Andrea Spinelli, Jul 20, 2004
    #3
  4. John

    Josh Guest

    It may be the ./ you're using to locate the file. The present
    directory may not be where you're assuming it is. Instead, I'd use a
    full path. As an FYI, you can also use system variables:

    log4j.appender.R.File=${catalina.home}/webapps/yourapp/dir/regreporting.log
    Josh, Jul 20, 2004
    #4
    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. Jim
    Replies:
    0
    Views:
    5,988
  2. Rodolfo
    Replies:
    0
    Views:
    951
    Rodolfo
    Jul 12, 2004
  3. jAnO!
    Replies:
    2
    Views:
    545
    Son KwonNam
    Jul 23, 2004
  4. willirl
    Replies:
    3
    Views:
    702
    Sebastian Millies
    Feb 24, 2005
  5. Gianni Galore
    Replies:
    0
    Views:
    1,269
    Gianni Galore
    Sep 8, 2010
Loading...

Share This Page