wood burning stoves*
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 Android Security Essentials Live Lessons this week in the Android 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

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

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

    Madhav Lakkapragada
    Ranch Hand

    Joined: Jun 03, 2000
    Posts: 5040

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

    Joined: Jan 21, 2011
    Posts: 29

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

    Log log = LogFactory.getLog((getClass()));

    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.
    wood burning stoves
    subject: Configuring Log4j in my Web App
    Similar Threads
    ServletException logged differently in Tomcat 5.5 and Tomcat 6.0
    Sun's Logger to log message in App Server log (SystemOut.log in WAS)
    Log message in SystemOut.log in WAS5.1x using Sun's logging API
    Error : do_service_time_request
    JMSappender onMessage(Message message) in MDB