Archivo de la etiqueta: logs

Working with Wowza logs


Improve logs management and rotation over linux, combining Log4j and LogRotate.

Modify the log4j.properties for using other Appender:

# Access appender
log4j.appender.serverAccess=org.apache.log4j.RollingFileAppender
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=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

Create the logrotate configuration file into Centos/RedHat the path is:

nano /etc/logrotate.d/wowza
/usr/local/WowzaMediaServer/logs/*.log {
       rotate 3
       size=512M
       compress
       copytruncate
       missingok
}

And the last step is you have very big logs files like is my case, and into one day I can have 2 GB of logs or more, move the log rotate for check every hour instead of every day

mv /etc/cron.daily/logrotate /etc/cron.hourly/

Inspired in this post: http://nicerhttpd.blogspot.com/2008/11/logrotate-and-log4j.html

UPDATE:
Other way to work with Wowza logs, can be using external Jar for rotate the logs by Size and Time, this way if you are running into WinOS or don’t like to use LogRotate for this task can have similar functionality

For more details can check the Wowza Forum post: http://www.wowza.com/forums/content.php?263-Logging-How-to-use-TimeAndSizeRollingAppender

Awstats mod for process Wowza Stats

Download the package from this link:

AWStats Mod for WowzaMediaServer (3734)
Awstats mod conf file (2608)

Add this lines into your Apache configuration:

#
# Directives to allow use of AWStats as a CGI
#

Alias /awstatsclasses /usr/local/awstats-wmc/wwwroot/classes/
Alias /awstatscss /usr/local/awstats-wmc/wwwroot/css/
Alias /awstatsicons /usr/local/awstats-wmc/wwwroot/icon/
ScriptAlias /awstats/ /usr/local/awstats-wmc/wwwroot/cgi-bin/

#
# This is to permit URL access to scripts/files in AWStats directory.
#

AddHandler cgi-script cgi pl
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all

Setting up the Crontab for update the Stats automatically

*/5 * * * * /usr/local/awstats-wmc/tools/awstats_updateall.pl now > /var/log/awstats.log

Setting up the Wowza Log Appender for save the information in the format then Awstats will be understand

For doit this edit the log4j.properties normally into this path:

 /usr/local/WowzaMediaServer/conf/log4j.properties 

Add this appender:

 # Statistics appender (to use this appender add "serverAWStats" to the list of appenders in the first line of this file)

log4j.appender.serverAWStats=org.apache.log4j.DailyRollingFileAppender
log4j.appender.serverAWStats.DatePattern='.'yyyy-MM-dd
log4j.appender.serverAWStats.File=${com.wowza.wms.ConfigHome}/logs/wmconsulting_stats.log
log4j.appender.serverAWStats.layout=com.wowza.wms.logging.ECLFPatternLayout
log4j.appender.serverAWStats.layout.Fields=date,time,c-proto,c-ip,c-referrer,x-status,cs-uri-stem,sc-bytes,x-duration,x-sname,sc-stream-bytes,cs-stream-bytes,x-ctx,c-proto,x-appinst
log4j.appender.serverAWStats.layout.OutputHeader=true
log4j.appender.serverAWStats.layout.QuoteFields=false
log4j.appender.serverAWStats.layout.Delimeter=tab
log4j.appender.serverAWStats.layout.EventInclude=destroy

This way the logs will rotate automatically every day, and you can move this logs to the stats server… of curse you will have 1 day of delay with the stats… if the Awstats is on the same server than Wowza, you can update the logs every five minutes or less depend of your needs…

Test your configuration running the command manually

First run:

/usr/local/awstats-wmc/wwwroot/cgi-bin/awstats.pl -config=your.site.com

Update run:

/usr/local/awstats-wmc/wwwroot/cgi-bin/awstats.pl -update -config=site.com  -showdropped

Real Time demo:

VOD Files
Live Streams

Here a few ScreenShots: