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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    6,243
    Alexandra Stehman
    Jan 19, 2004
  2. Jim
    Replies:
    0
    Views:
    6,295
  3. Alex Hunsley
    Replies:
    2
    Views:
    13,888
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  4. Rodolfo
    Replies:
    0
    Views:
    1,196
    Rodolfo
    Jul 12, 2004
  5. jAnO!
    Replies:
    2
    Views:
    674
    Son KwonNam
    Jul 23, 2004
  6. willirl
    Replies:
    3
    Views:
    899
    Sebastian Millies
    Feb 24, 2005
  7. joes
    Replies:
    1
    Views:
    3,098
  8. Gianni Galore
    Replies:
    0
    Views:
    1,544
    Gianni Galore
    Sep 8, 2010
Loading...