• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 678
  • Last Modified:

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

0
xenia27
Asked:
xenia27
  • 4
  • 3
1 Solution
 
RajeshpolaCommented:
Can you please try the below two options.

log4j.appender.R.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.R.DatePattern="'_'yyyy-MM-dd"

Let me know if it doesnt solve the issue.
0
 
xenia27Author Commented:
I tried "log4j.appender.R.DatePattern="'_'yyyy-MM-dd""...but it didn't work...
should I put both lines in the same file?
0
 
RajeshpolaCommented:
log4j.appender.R.DatePattern="'_'yyyy-MM-dd instead of this try putting any one of those two lines in the same file.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
xenia27Author Commented:
I tried both lines...none of them worked...there is no date on the file name...
0
 
RajeshpolaCommented:
can you replace the property "log4j.appender.R=org.apache.log4j.RollingFileAppender" with this "log4j.appender.R=org.apache.log4j.DailyRollingFileAppender" and test it.
0
 
xenia27Author Commented:
now...it didn't create another log file if the log file size reaches the limit.
0
 
RajeshpolaCommented:
I guess the rolling will happen daily basis , it will create one log file for each day.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now