log4j2logrotaterundeck

How to properly rotate and archive rundeck logs


I am using 2.6.4-1. Since rundeck logs dont archive or rotate themselves or don't drop a conf into logrotate with the installation; what is the best way to rotate and archive it..?

I can manually drop a config into logrotate so it can rotate and archive it, may be I can use copytruncate since Java apps (such as Rundeck) usually ignore UNIX signals like SIGHUP and SIGUSR1 but what stopping me using logrotate is, rundeck is trying to rotate the logs with appending a date stamp and keeping it there without archiving.This makes logrotate not working as expected. Since the size of the logs keep on growing, any alternatives for rundeck log rotation,archiving.

Or help me on how to avoid rundeck to try rotate the logs with appending a date stamp into the log name. Like rundeck.access.log turns to rundeck.access.log.2017-06-02 which makes logrotate to not working on archiving it.

Thanks in advance. Leo Prince


Solution

  • As you already know that Rundeck uses log4f as its application logging facility. All logging is controlled by log4j. The log config file is RD_BASE/log4j.properties or RD_BASE/etc/log4j.properties if you are using launcher.

    If you look into your log4j.properties file. You will find for the config for all files that appear under /var/log/rundeck/ directory have following setting:

    log4j.appender.cmd-logger=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.cmd-logger.file=/var/log/rundeck/command.log
    log4j.appender.cmd-logger.datePattern='.'yyyy-MM-dd
    log4j.appender.cmd-logger.append=true
    log4j.appender.cmd-logger.layout=org.apache.log4j.PatternLayout
    log4j.appender.cmd-logger.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c - %m%n
    

    org.apache.log4j.DailyRollingFileAppender makes log file rotate dailly.

    The log file name will have a dateParttern as '.'yyyy-MM-dd


    log4j log rotation and archive

    TimeBasedRollingPolicy

    The setting you are looking for is FileNamePattern

    Here is an example on how to log rotate and archive using log4j How to make log files rotate per day and zip old rotated logs using log4j.properties