DeployR log rotation to avoid large catalina.out

Are you facing a situation where your DeployR installations catalina.out file is growing huge after being in operation for a long time? DeployR has a webapp which is deployed on tomcat servlet container. Tomcat's default log file catalina.out has no rotation facility. So if tomcat has been running for a while without restarts which could be days or months, and application logs are not being directed to a different file, it can grow quite big and potentially cause disk space issues besides being difficult to sift through such a huge file. There are ways to indirectly rotate catalina.out but they can be difficult to implement (see: The answer is to actually not log application logs to catalina.out but direct them to a custom file(s) using a logging framework like log4j.

DeployR uses log4j for logging but by default it is configured for the 'console' appender and goes to 'stdout' which means all of the log messages generated by DeployR webapp will go to Tomcat's catalina.out file which will keep growing until tomcat is restarted.

You can edit the deployr.groovy configuration file to direct the log messages to a custom file location using log4j's 'rollingFile' appender which will allow you to rotate the log file once it reaches a certain size.

Below is a sample configuration file to do that (replace the original log4j configuration block in deployr.groovy (restart tomcat after changing this):

log4j = {
    appenders {
        rollingFile name: 'myfile', maxFileSize: '10MB', maxBackupIndex:10,
        file: 'C:\\Revolution\\DeployR-7.3\\Apache_Tomcat\\logs\\deployr.log',
        layout: pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss.SSS} | %p | %c | %t | %m | %x%n')
        console name: 'stdout', layout: pattern(conversionPattern: '[%5p %d{HH:mm:ss:S}] %c{1} %m%n')

    root {
        info "myfile"

    error   'org.springframework',

Based on the above configuration, the rollingFile appender, log4j will direct the log to 'C:\Revolution\DeployR-7.3\Apache_Tomcat\logs\deployr.log'. The 'maxFileSize' parameter determines at what size the log should be rotated. So in this case once deployr.log reaches the size of 10MB, it will be backed up to different file named 'deployr.log.1' and new logging will start to an empty deployr.log file (if a previously backed up file with same name exists, it will be renamed to 'deployr.log.2' and so on for each of the backed up log file). 'maxBackupIndex' refers to how many backed up files will be kept. Once number of backed up files reach the 'maxBackupIndex' value, the oldest of the file will be deleted (in this case  'deployr.log.10').

Comments (0)

Skip to main content