Apache Tomcat std_out logs can be rotated by using log4j functionality based on its file size as mentioned below.
Modify log4j.properties
log4j.rootCategory=DEBUG,stdout, Sample
#### First appender writes to console
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.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
#### Second appender writes to a file
log4j.appender.Sample=org.apache.log4j.RollingFileAppender
log4j.appender.Sample.File=D:/ApacheSoftwareFoundation/Tomcat5.5/logs/SampleSiteLogs.txt
### Control the maximum log file size
### Archive log files
### (one backup file here Attribute MaxBackupIndex is where we can define max no of files to be written)
log4j.appender.Sample.MaxFileSize=100KB
log4j.appender.Sample.MaxBackupIndex=5
log4j.appender.Sample.layout=org.apache.log4j.PatternLayout
log4j.appender.Sample.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %p %t %c - %m%n
Modify log4j.properties
log4j.rootCategory=DEBUG,stdout, Sample
#### First appender writes to console
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.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
#### Second appender writes to a file
log4j.appender.Sample=org.apache.log4j.RollingFileAppender
log4j.appender.Sample.File=D:/ApacheSoftwareFoundation/Tomcat5.5/logs/SampleSiteLogs.txt
### Control the maximum log file size
### Archive log files
### (one backup file here Attribute MaxBackupIndex is where we can define max no of files to be written)
log4j.appender.Sample.MaxFileSize=100KB
log4j.appender.Sample.MaxBackupIndex=5
log4j.appender.Sample.layout=org.apache.log4j.PatternLayout
log4j.appender.Sample.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %p %t %c - %m%n
No comments:
Post a Comment