Personal tools
You are here: Home Leocornus Leocornus Buildout Config Repository. Configuration and setup for logrotate

Configuration and setup for logrotate

logrotate to rotate and housekeeping all kind of log files. including the following popular applications:

  • Nginx
  • Tomcat
  • MariaDB

logrotate basic

The basic logrotate configruation file:

rotate 5

# logrotate conf file for Nginx log files

Nginx logrotate config

Here is a sample for Nginx logrotate config:

# this is like a sample file:
${settings:log-directory}/frontend*.log {
        /bin/kill -USR1 $(cat ${settings:log-directory}/

The kill signal USR1 is for Reopen log files. The details list of Nginx server signals could be find in Nginx Command Line wiki page.

Tomcat logrotate config

Tomcat's logging system is based on Log4j / Java Logging API. It could be configurated to rotate logging file every day. But it will NOT do the housekeeping working for all those log files.

The choice here is turn off the rotation for tomcat logging settings, and use the logrotate to rotate and housekeeping log files.

Steps need to be done:

  • using jsvc to run tomcat as a daemon on Unix.
  • config tomcat logging to turn off logging rotating, 2 files: and server.xml
  • logrotat configuration, using jsvc kill signal SIGUSR1 to reopen log files.

Here is a sample logrotate configuration file for tomcat on jsvc:

/path/to/tomcat/catalina/log.files {
        /bin/kill -SIGUSR1 /path/to/
Document Actions