Difference between revisions of "Simple rsyslog Configuration"

From MythTV Official Wiki
Jump to: navigation, search
(Simple rsyslog Configuration)
(One intermediate revision by the same user not shown)
Line 173: Line 173:
 
$template MythTVLog,"%TIMESTAMP% %HOSTNAME% %msg%\n"
 
$template MythTVLog,"%TIMESTAMP% %HOSTNAME% %msg%\n"
  
# For programs that DON'T use mythlogserver:
+
# For programs that DON'T use mythlogserver.  This template will create a log file named
 +
# /var/log/[Replaced_with_Name_Of_Myth_Program].log.
 
$template noLogServerLog,"/var/log/mythtv/%programname%.log"
 
$template noLogServerLog,"/var/log/mythtv/%programname%.log"
 +
 +
# By default this results in output that matches the default traditional output. 
 +
# This template could used to modify the output
 +
# $template noLogServerLogFormat,"%TIMESTAMP% %HOSTNAME% %SYSLOGTAG% %msg%\n"
 +
# and by changing the following line to
 +
# if $syslogfacility-text == 'local7' and $programname startswith 'myth' then ?noLogServerLog;noLogServerLogFormat
 +
 +
  
 
if $syslogfacility-text == 'local7' and $msg startswith ' mythbackend' then /var/log/mythtv/mythbackend.log;MythTVLog
 
if $syslogfacility-text == 'local7' and $msg startswith ' mythbackend' then /var/log/mythtv/mythbackend.log;MythTVLog

Revision as of 09:00, 4 September 2012

rsyslog is an implementation of syslog. This page provides basic information on configuring rsyslog for use with MythTV, but additional information can be found on the rsyslog web site and wiki. (See also Simple_syslog-ng_Configuration)

Simple rsyslog Configuration

This configuration uses a simple approach to logging which separates log lines into different files based on application name. This approach has the benefit that it allows logging to any desired syslog facility and will prevent non-MythTV application logging from getting into MythTV log files (even if another service or application uses the same syslog facility). This configuration assumes that all MythTV applications use syslog logging. This is done by specifying the command-line argument --syslog <facility> to all MythTV applications, for example:

mythbackend --syslog local7

To use the configuration, place the configuration file at /etc/rsyslog.d/40-mythtv.conf, create/update the initial log files with appropriate ownership and permissions, restart rsyslogd, then start MythTV applications with --syslog local7. The commands to create/update the initial log files are given, below, for easier copy/paste (permissions, here, are appropriate for Ubuntu-based systems--change owner and group, as required, for your system):

sudo install -d -m0755 -o syslog -g adm /var/log/mythtv
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythbackend.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythfrontend.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythjobqueue.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmediaserver.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythtv-setup.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythfilldatabase.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythcommflag.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythpreviewgen.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythtranscode.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmetadatalookup.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythutil.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythwelcome.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythshutdown.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmessage.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythlcdserver.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythccextractor.log
sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythavtest.log


Author unknown
Description Example configuration file for using rsyslog for MythTV application logging.
Supports Version25.png  



Script.png /etc/rsyslog.d/40-mythtv.conf

# Begin /etc/rsyslog.d/40-mythtv.conf

# While rsyslog should be able to create the required directories and files,
# existing directories and files will not be updated with required ownership
# and permissions. Therefore, to ensure this logging configuration works,
# regardless of existing log files, the required directories and files should
# be updated with appropriate permissions before starting rsyslog. The
# following commands can be used to do this (with permissions, here, given
# for use on Ubuntu-based systems--change owner and group, as required, for
# your system):
#
# sudo install -d -m0755 -o syslog -g adm /var/log/mythtv
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythbackend.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythfrontend.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythjobqueue.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmediaserver.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythtv-setup.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythfilldatabase.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythcommflag.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythpreviewgen.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythtranscode.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmetadatalookup.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythutil.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythwelcome.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythshutdown.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythmessage.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythlcdserver.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythccextractor.log
# sudo install -m0644 -o syslog -g adm /dev/null /var/log/mythtv/mythavtest.log

# Make MythTV logs readable by world
$FileCreateMode 0644

# Send all logging from MythTV applications to application-specific log files.
if $programname == 'mythbackend' then /var/log/mythtv/mythbackend.log
& ~
if $programname == 'mythfrontend' then /var/log/mythtv/mythfrontend.log
& ~
if $programname == 'mythjobqueue' then /var/log/mythtv/mythjobqueue.log
& ~
if $programname == 'mythmediaserver' then /var/log/mythtv/mythmediaserver.log
& ~
if $programname == 'mythtv-setup' then /var/log/mythtv/mythtv-setup.log
& ~
if $programname == 'mythfilldatabase' then /var/log/mythtv/mythfilldatabase.log
& ~
if $programname == 'mythcommflag' then /var/log/mythtv/mythcommflag.log
& ~
if $programname == 'mythpreviewgen' then /var/log/mythtv/mythpreviewgen.log
& ~
if $programname == 'mythtranscode' then /var/log/mythtv/mythtranscode.log
& ~
if $programname == 'mythmetadatalookup' then /var/log/mythtv/mythmetadatalookup.log
& ~
if $programname == 'mythutil' then /var/log/mythtv/mythutil.log
& ~
if $programname == 'mythwelcome' then /var/log/mythtv/mythwelcome.log
& ~
if $programname == 'mythshutdown' then /var/log/mythtv/mythshutdown.log
& ~
if $programname == 'mythmessage' then /var/log/mythtv/mythmessage.log
& ~
if $programname == 'mythlcdserver' then /var/log/mythtv/mythlcdserver.log
& ~
if $programname == 'mythccextractor' then /var/log/mythtv/mythccextractor.log
& ~
if $programname == 'mythavtest' then /var/log/mythtv/mythavtest.log
& ~

# Set FileCreateMode back to default.  This should be the same value as specified
# in the /etc/rsyslog.conf file.
$FileCreateMode 0640

# End /etc/rsyslog.d/40-mythtv.conf



Author unknown
Description Example configuration file for using rsyslog for MythTV application logging.
Supports Version26.png 


In versions 0.26 and above, Mythlogserver handles all logging requests.

Each log entry would have the program name: mythlogserver before the name of the program that called for the log. The MythTVLog template in the following file removes the mythlogserver text.


Important.png Note: By default, log entries will have control codes converted to their octal values (e.g. new-lines will show up as #012.) The conversion can be prevented by adding $EscapeControlCharactersOnReceive off to the following file. This, however, affects ALL syslog logging, not just MythTV. See warnings here.

The following is an example of a typical MythTV multi-line message as it appears in the log file:

... CoreContext main.cpp:748 (main) #012===============================================================#012| Attempting to contact the master backend for rescheduling.  |#012| If the master is not running, rescheduling will happen when |#012| the master backend is restarted.                            |#012===============================================================

By adding the $EscapeControlCharactersOnReceive off in the file below, the above will print in its intended format:

... CoreContext main.cpp:748 (main) 
===============================================================
| Attempting to contact the master backend for rescheduling.  |
| If the master is not running, rescheduling will happen when |
| the master backend is restarted.                            |
===============================================================


Script.png /etc/rsyslog.d/40-mythtv.conf

# Begin /etc/rsyslog.d/40-mythtv.conf for MythTV Version 0.26 and on.

# Make MythTV logs readable by world
$FileCreateMode 0644

#
# Sample Log Entry: Aug 31 12:08:11 mythosttname mythlogserver: mythbackend[3139]: I HouseKeeping housekeeper.cpp:221 ...
#

# Control-code conversion. The default is on.
$EscapeControlCharactersOnReceive off

# This template drops the mythlogserver: $programname, so messages APPEAR to have the
# traditional programname[<PID>] tag (which is really part of the $msg.)
$template MythTVLog,"%TIMESTAMP% %HOSTNAME% %msg%\n"

# For programs that DON'T use mythlogserver.  This template will create a log file named 
# /var/log/[Replaced_with_Name_Of_Myth_Program].log.
$template noLogServerLog,"/var/log/mythtv/%programname%.log"

# By default this results in output that matches the default traditional output.  
# This template could used to modify the output 
# $template noLogServerLogFormat,"%TIMESTAMP% %HOSTNAME% %SYSLOGTAG% %msg%\n"
# and by changing the following line to
# if $syslogfacility-text == 'local7' and $programname startswith 'myth' then ?noLogServerLog;noLogServerLogFormat



if $syslogfacility-text == 'local7' and $msg startswith ' mythbackend' then /var/log/mythtv/mythbackend.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythfrontend' then /var/log/mythtv/mythfrontend.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythjobqueue' then /var/log/mythtv/mythjobqueue.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythmediaserver' then /var/log/mythtv/mythmediaserver.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythtv-setup' then /var/log/mythtv/mythtv-setup.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythfilldatabase' then /var/log/mythtv/mythfilldatabase.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythcommflag' then /var/log/mythtv/mythcommflag.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythpreviewgen' then /var/log/mythtv/mythpreviewgen.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythtranscode' then /var/log/mythtv/mythtranscode.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythmetadatalookup' then /var/log/mythtv/mythmetadatalookup.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythutil' then /var/log/mythtv/mythutil.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythwelcome' then /var/log/mythtv/mythwelcome.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythshutdown' then /var/log/mythtv/mythshutdown.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythlcdserver' then /var/log/mythtv/mythlcdserver.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythccextractor' then /var/log/mythtv/mythccextractor.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythavtest' then /var/log/mythtv/mythavtest.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $msg startswith ' mythlogserver' then /var/log/mythtv/mythlogserver.log;MythTVLog
& ~
if $syslogfacility-text == 'local7' and $programname startswith 'myth' then ?noLogServerLog
& ~

# Set FileCreateMode back to default. This should be the same value as specified
# in the /etc/rsyslog.conf file.
$FileCreateMode 0640

# End /etc/rsyslog.d/40-mythtv.conf