=^.^=

Rotate Red5 Logs Without logrotate

karma

If you are capturing log output from Red5 via stdout and stdin as I had configured in this init script you will not be able to use logrotate and reliably preserve data as the active files are not replaced until the daemon has been restarted, losing anything that happened between then and the last rotation. Logging this way also suffers from a lack of timestamping. Fortunately, red5 has the capacity to rotate log files itself. Disable logging from stdout/stdin and replace the following portion of /opt/red5/conf/logback.xml:

        <appender name="FILE" class="ch.qos.logback.core.FileAppender">
                <File>log/red5.log</File>
                <Append>false</Append>
                <encoder>
                        <pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</pattern>
                </encoder>
        </appender>
        <appender name="ERRORFILE" class="ch.qos.logback.core.FileAppender">
                <File>log/error.log</File>
                <Append>false</Append>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>WARN</level>
        </filter>
                <encoder>
                        <pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</pattern>
                </encoder>
        </appender>

with:

        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>/var/log/red5/red5.log</File>
          
            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <FileNamePattern>log/red5.%d{yyyy-MM-dd}.log</FileNamePattern>
              <!-- keep 30 days worth of history -->
              <MaxHistory>30</MaxHistory>
            </rollingPolicy>

            <layout class="ch.qos.logback.classic.PatternLayout">
              <Pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</Pattern>
            </layout>
          </appender>
          <appender name="ERRORFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
            <File>/var/log/red5/error.log</File>

            <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
              <FileNamePattern>log/error.%d{yyyy-MM-dd}.log</FileNamePattern>
              <!-- keep 30 days worth of history -->
              <MaxHistory>30</MaxHistory>
            </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
                <level>WARN</level>
        </filter>
            <layout class="ch.qos.logback.classic.PatternLayout">
              <Pattern>%d{ISO8601} [%thread] %-5level %logger{35} - %msg%n</Pattern>
            </layout>
          </appender>

Thank you to the bigbluebutton staff.

Comments

There are no comments for this item.