Link to home
Start Free TrialLog in
Avatar of xenia27
xenia27Flag for Taiwan, Province of China

asked on

Tomcat log4j and system.out

I try to use log4j to create a new log when the log size reaches the limitation I set.  However, I don't know why the date is just not shown on the log file name...Also, how can I just record system.out message in my log??

Any suggestion how I should change my properties file?
# A default log4j configuration for log4j users.
#
# To use this configuration, deploy it into your application's WEB-INF/classes
# directory.  You are also encouraged to edit it as you like.

# Configure the console as our one appender
log4j.rootLogger=debug, R 
log4j.appender.R=org.apache.log4j.RollingFileAppender 
log4j.appender.R.File=${catalina.home}/logs/my_logging
log4j.appender.R.DatePattern='_'yyyy-MM-dd'.log'
log4j.appender.R.MaxFileSize=50MB 
log4j.appender.R.MaxBackupIndex=10 
log4j.appender.R.layout=org.apache.log4j.PatternLayout 
log4j.appender.R.layout.ConversionPattern=%d   %-5p   %c{2}   -   %m%n 
log4j.logger.org.apache.catalina=DEBUG, R   

# tighten logging on the DataNucleus Categories
log4j.category.DataNucleus.JDO=WARN, A1
log4j.category.DataNucleus.Persistence=WARN, A1
log4j.category.DataNucleus.Cache=WARN, A1
log4j.category.DataNucleus.MetaData=WARN, A1
log4j.category.DataNucleus.General=WARN, A1
log4j.category.DataNucleus.Utility=WARN, A1
log4j.category.DataNucleus.Transaction=WARN, A1
log4j.category.DataNucleus.Datastore=WARN, A1
log4j.category.DataNucleus.ClassLoading=WARN, A1
log4j.category.DataNucleus.Plugin=WARN, A1
log4j.category.DataNucleus.ValueGeneration=WARN, A1
log4j.category.DataNucleus.Enhancer=WARN, A1
log4j.category.DataNucleus.SchemaTool=WARN, A1

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rajeshpola
Rajeshpola

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenia27

ASKER

I tried "log4j.appender.R.DatePattern="'_'yyyy-MM-dd""...but it didn't work...
should I put both lines in the same file?
Avatar of Rajeshpola
Rajeshpola

log4j.appender.R.DatePattern="'_'yyyy-MM-dd instead of this try putting any one of those two lines in the same file.
Avatar of xenia27

ASKER

I tried both lines...none of them worked...there is no date on the file name...
can you replace the property "log4j.appender.R=org.apache.log4j.RollingFileAppender" with this "log4j.appender.R=org.apache.log4j.DailyRollingFileAppender" and test it.
Avatar of xenia27

ASKER

now...it didn't create another log file if the log file size reaches the limit.
I guess the rolling will happen daily basis , it will create one log file for each day.