• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts Logging

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using struts 1.1 with Tomcat5.0.16 for my project. I have configured tomcat's server.xml file and set my own context (its in D:\myweb). Not I want to have my own log file in D:\myweb\WEB-INF\logs folder. can anyone help me how i can do it. Its an urgency.

Thanks in advance.

N Nanda
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by N Nanda:
Hi all,

I am using struts 1.1 with Tomcat5.0.16 for my project. I have configured tomcat's server.xml file and set my own context (its in D:\myweb). Not I want to have my own log file in D:\myweb\WEB-INF\logs folder. can anyone help me how i can do it. Its an urgency.

Thanks in advance.

N Nanda



download log4j, place in lib directory of webapps/lib

configure your log4j.properties like below and put it under web-inf/classes

# Global logging configuration
log4j.rootLogger=WARN, fileout, stdout
# replace com.lecare with your package names for which you want logging support
log4j.logger.com.lecare=DEBUG

# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d{HH:mm:ss} [%t] - %m%n

# Rolling log file output...
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=c:/actions.log
#log4j.appender.fileout.File=c:/webserve/log/actions.log
log4j.appender.fileout.MaxFileSize=1024KB
log4j.appender.fileout.MaxBackupIndex=5
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.ConversionPattern=%5p %d{dd MMM HH:mm:ss} [%t] (%F:%L) - %m%n



import logging classes:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

declare logger for the class
private Log logger = LogFactory.getLog(this.getClass());


for more information on using log4j read log4j documentation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic