Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Specify the Log File address as RootDir/Logs/Error.log in Log4j

807603Nov 22 2007 — edited Nov 26 2007
I have a web application,

How to configure the log4j Rolling file Appender in that.

I want to logs to be redirected to the RootDir/logs/Error.log.

Currently, I m using following configuration:

# This file must live on the classpath of the jvm
#
# Set root logger level to DEBUG and log to both stdout and rollingFile appenders
# (see below for their definitions)
# The set of possible levels are: DEBUG, INFO, WARN, ERROR and FATAL
log4j.rootLogger=INFO, stdout, R

####### Console appender ######
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
# The pattern: Date Priority (Filename:Line Number) - Message\n
log4j.appender.stdout.layout.ConversionPattern=%d %-5p (%F:%L) - %m%n

#### Second appender writes to a file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=Error.log

# Control the maximum log file size
log4j.appender.R.MaxFileSize=100KB
# Archive log files (one backup file here)
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %-5p (%F:%L) - %m%n

Thanks for your replies in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2007
Added on Nov 22 2007
9 comments
1,197 views