How to configure log rolling by time and size

This article describes how to roll over wowzamediaserver_access.log files at a precise time or size. By default, the Wowza media server logs roll over daily but only if there's new activity.

Note: Wowza Media Server™ 3.6.2 or later is required.

To roll over by time

  1. Open the [install-dir]/conf/log4j.properties file in a text editor and ensure that the first entry in the Access appender section is:
    log4j.appender.serverAccess=org.apache.log4j.DailyRollingFileAppender
    If RollingFileAppender is enabled, comment it out. For example:
    log4j.appender.serverAccess=org.apache.log4j.DailyRollingFileAppender
    #log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
  2. In the Access appender section, update the date pattern in the following line to the specified time duration at which log files should rollover.
    For example, to change the DatePattern to enable rollover every minute:
    log4j.appender.serverAccess.DatePattern='.'yyyy-MM-dd-hh-mm
  3. The Access appender section of your log4j.properties file should now look something like this:
    # Access appender
    log4j.appender.serverAccess=org.apache.log4j.DailyRollingFileAppender
    #log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
    log4j.appender.serverAccess.DatePattern='.'yyyy-MM-dd-hh-mm
    log4j.appender.serverAccess.File=${com.wowza.wms.ConfigHome}/logs/wowzamediaserver_access.log
    log4j.appender.serverAccess.layout=com.wowza.wms.logging.ECLFPatternLayout
    #log4j.appender.serverAccess.layout.Fields=x-severity,x-category,x-event;date,time,c-client-id,c-ip,c-port,cs-bytes,sc-bytes,x-duration,x-sname,x-stream-id,x-spos,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment
    log4j.appender.serverAccess.layout.Fields=date,time,tz,x-event,x-category,x-severity,x-status,x-ctx,x-comment,x-vhost,x-app,x-appinst,x-duration,s-ip,s-port,s-uri,c-ip,c-proto,c-referrer,c-user-agent,c-client-id,cs-bytes,sc-bytes,x-stream-id,x-spos,cs-stream-bytes,sc-stream-bytes,x-sname,x-sname-query,x-file-name,x-file-ext,x-file-size,x-file-length,x-suri,x-suri-stem,x-suri-query,cs-uri-stem,cs-uri-query
    log4j.appender.serverAccess.layout.OutputHeader=true
    log4j.appender.serverAccess.layout.QuoteFields=false
    log4j.appender.serverAccess.layout.Delimeter=tab
  4. Restart Wowza Media Server to enable the changes.

To roll over by size

  1. Open the [install-dir]/conf/log4j.properties file in a text editor and ensure that the first enabled entry in the Access appender section is:
    log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
    If DailyRollingFileAppender is enabled, comment it out. For example:
    #log4j.appender.serverAccess=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
  2. Add the following line to the bottom of the Access appender section:
    log4j.appender.serverAccess.MaxFileSize=100KB
    This configures a new log file to be created when the previous log reaches 100 KB. You can change this to a maximum of 204800 KB (200 MB) or to another more reasonable size for your setup.
     
  3. Add the following line directly under the new entry that you added in the previous step (change 10 to the maximum number of log files that you want to store at the specified size):
    log4j.appender.serverAccess.MaxBackupIndex=10
  4. The Access appender section of your log4j.properties file should now look something like this:
    # Access appender
    #log4j.appender.serverAccess=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
    log4j.appender.serverAccess.DatePattern='.'yyyy-MM-dd
    log4j.appender.serverAccess.File=${com.wowza.wms.ConfigHome}/logs/wowzamediaserver_access.log
    log4j.appender.serverAccess.layout=com.wowza.wms.logging.ECLFPatternLayout
    #log4j.appender.serverAccess.layout.Fields=x-severity,x-category,x-event;date,time,c-client-id,c-ip,c-port,cs-bytes,sc-bytes,x-duration,x-sname,x-stream-id,x-spos,sc-stream-bytes,cs-stream-bytes,x-file-size,x-file-length,x-ctx,x-comment
    log4j.appender.serverAccess.layout.Fields=date,time,tz,x-event,x-category,x-severity,x-status,x-ctx,x-comment,x-vhost,x-app,x-appinst,x-duration,s-ip,s-port,s-uri,c-ip,c-proto,c-referrer,c-user-agent,c-client-id,cs-bytes,sc-bytes,x-stream-id,x-spos,cs-stream-bytes,sc-stream-bytes,x-sname,x-sname-query,x-file-name,x-file-ext,x-file-size,x-file-length,x-suri,x-suri-stem,x-suri-query,cs-uri-stem,cs-uri-query
    log4j.appender.serverAccess.layout.OutputHeader=true
    log4j.appender.serverAccess.layout.QuoteFields=false
    log4j.appender.serverAccess.layout.Delimeter=tab
    log4j.appender.serverAccess.MaxFileSize=100KB
    log4j.appender.serverAccess.MaxBackupIndex=10
  5. Restart Wowza Media Server to enable the changes.

If you're having problems or want to discuss this article, post in our forum.