• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 653
  • 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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