• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write errors to a file using Log4j.Properties  RSS feed

 
Anamika Gubba
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a Struts applications using Tomcat. I created Log4j.Properties file under folder called SRC. I am able append errors to Tomcat console but I want to write errors to the file. Can anybody help me in writing errors to a file using Log4j.Properties file.

Thanks in advance,
Anamika
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
 
Anamika Gubba
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You. I will go through the documentation.

-Anamika
 
Anamika Gubba
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am able to write logger.info message to file but not on the console. Please let me know how to write logger.info messages to both console as well as to the file.

This is how my Log4j.property file look:

log4j.rootLogger=INFO, R

#
#Append to Console
#
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
#
# Print the date in ISO 8601 format
#
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#
# Append to IUPS ReportsLog.log file
#
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.File=/Tomcat 5.0/logs/IUPS ReportsLog.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
#
# Print the date in ISO 8601 format
#
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

#
# Application logging options
#
#log4j.logger.org.apache=DEBUG
#log4j.logger.org.apache=INFO
#log4j.logger.org.apache.struts=DEBUG
#log4j.logger.org.apache.struts=INFO

Please let me know.

Thanks in advance,
Anamika
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
log4j.rootLogger=INFO, R


Change this to:



Also, the following link might help in configuring the log4j file:



Note: Could not enclose the above URL in a URL tag, it's giving some errors.

[ May 17, 2006: Message edited by: jaikiran pai ]

[ May 17, 2006: Message edited by: jaikiran pai ]
[ May 17, 2006: Message edited by: jaikiran pai ]
 
Anamika Gubba
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It worked. Now I am able to write logger.info messages to both on to the console and as well as to the file.

Thanks once again,
Anamika
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!