Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Configuring Log4j in my Web App

 
s mahen perera
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 101
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 5040
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    s mahen perera
    Ranch Hand
    Posts: 101
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Madhav
     
    s mahen perera
    Ranch Hand
    Posts: 101
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Madhav
     
    Prateek Kumar Singh
    Ranch Hand
    Posts: 30
    Eclipse IDE Hibernate Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic