I am really fed up in not being able to solve the tomcat log rotation problem in one our windows server after putting countless hours in it and after trying out various solutions.
Methods tried so far:
cronolog
didn't work, no files where being created after setting it up.
Managed to configure log4j
with DailyRollingFile
appender globally for Tomcat, the log files are being created without extension and are not being rotated.
Tried DatedFileAppender
too, but didn't get much success.
Tried log4jna
based Windows Event Log appender
for log4j, there didn't get success
Please suggest an easy method to finish this task.
logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large. Normally, logrotate is run as a daily cron job.
Apache Tomcat Logs Location in Windows By default, Apache Tomcat logs are stored in the install_dir/logs where the install_dir refers to the Apache Tomcat installation directory. The log files are stored in the logs directory.
Logrotate is a system utility that manages the automatic rotation and compression of log files. If log files were not rotated, compressed, and periodically pruned, they could eventually consume all available disk space on a system.
Apache Tomcat provides the configuration directory conf, that contains the file server.xml. At the bottom of this file, a line that includes the adjustments valve, called AccessLogValve must be un-commented and changed.
The default valve parameters and patterns can easily be modified through an editor. Your settings for the access log file for example may look like this:
<Valve
className="org.apache.catalina.valves.AccessLogValve."
directory="logs"
prefix="mysite."
suffix=".log"
pattern='%a %A %b %B %h %l %m %p %q %u %t "%r" %s %U %D %S'
resolveHosts="false"
rotatable="true"
fileDateFormat="yyyy-MM-dd"
/>
This sentence is from the Tomcat reference:
The fileDateFormat parameter allows a customized date format in the access log file name. The date format also decides how often the file is rotated. If you wish to rotate every hour, then set this value to: yyyy-MM-dd.HH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With