File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Configuring Log4j in my Web App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Configuring Log4j in my Web App" Watch "Configuring Log4j in my Web App" New topic
Author

Configuring Log4j in my Web App

s mahen perera
Ranch Hand

Joined: Mar 08, 2005
Posts: 101
Hi !!

I am developing a Web App using the Struts framework. Can someone pls tell me step by step what (like what is the jar required,,where to put the other configurations files etc )to do in order to configure Log 4j in it.

The end result should be to somehow display the log messages in the tomcat (The Sevlet Container i am using) console, for the log message i have given in the source code ,,, as for example.. logger.debug("log message");
Shawn A Hanna
Greenhorn

Joined: Jun 20, 2005
Posts: 1
You need to down load a copy of the latest log4j.jar file from Log4j logging services.
  • Place that Jar file to the WEB-INF/lib directory for each web application that you deploy.
  • Place your log4j.properties or your log4j.xml in the classpath of your web app ( usually in WEB-INF/classes).

  • s mahen perera
    Ranch Hand

    Joined: Mar 08, 2005
    Posts: 101
    Thanks Shawn,, appreciate if u can send some link which shows how to edit the log4j.properties file or a sample log4j.properties file,, . Basically i need to know how to change it according to my application. Thanks again

    Cheers
    Madhav Lakkapragada
    Ranch Hand

    Joined: Jun 03, 2000
    Posts: 5040
    Mahen,

    Please see this post for a sample log4j.xml file. The discussion in that thread is related to what you are trying to do.
    Good luck.

    - m


    Take a Minute, Donate an Hour, Change a Life
    http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
    s mahen perera
    Ranch Hand

    Joined: Mar 08, 2005
    Posts: 101
    Thanks Madhav
    s mahen perera
    Ranch Hand

    Joined: Mar 08, 2005
    Posts: 101
    Thanks Madhav
    Prateek Kumar Singh
    Greenhorn

    Joined: Jan 21, 2011
    Posts: 29


    Hi,
    my log4j.properties file present in web-inf and i'm using...

    Log log = LogFactory.getLog((getClass()));
    log.info("somthing");

    log4j.rootLogger=DEBUG, file


    but stll there is a warning...

    log4j:WARN No appenders could be found for logger (ca.ser).
    log4j:WARN Please initialize the log4j system properly.

    can you solve this issue.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Configuring Log4j in my Web App