Templated rsyslog Configuration

From MythTV Official Wiki
Revision as of 04:40, 18 January 2013 by Sphery (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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, Category:Syslog Configuration Files.

Templated Logging to local7 Facility

This configuration uses an alternate approach to logging based around rsyslog templates. This approach has the benefit that it will use an appropriate log file name, regardless of MythTV application names (and future changes/additions to the MythTV application suite). However, some distributions configure rsyslog in such a way that the templated configuration will not work. (For example, this configuration most likely will not work in Ubuntu, due to https://bugs.launchpad.net/ubuntu/+source/rsyslog/+bug/484336 and https://bugs.launchpad.net/ubuntu/+source/rsyslog/+bug/407862 .)

This configuration assumes that all MythTV applications use the local7 syslog facility for logging. This is done by specifying the command-line argument --syslog local7 to all MythTV applications, for example:

mythbackend --syslog local7

It also assumes that no other non-MythTV applications are using the local7 facility for logging.

To use the configuration, place the configuration file at /etc/rsyslog.d/40-mythtv-templated.conf, and restart rsyslogd, then start MythTV applications with --syslog local7.

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

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

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

# Use MythTV-specific file permissions.
# Comment this section to use syslog defaults.
# Ensure you reset syslog defaults at the bottom if you use this section.
$FileOwner syslog
$FileGroup syslog
$FileCreateMode 0644
$DirOwner syslog
$DirGroup syslog
$DirCreateMode 0755

# Specify a log file name format.  Ensure one of the following templates is
# uncommented.
#  - Use a single log file for all logging from any MythTV application:
#$template mythtvFile,"/var/log/mythtv/mythtv.log"
#  - Use a single log file per application:
$template mythtvFile,"/var/log/mythtv/%programname%.log"
#  - Use a separate log file per process:
#$template mythtvFile,"/var/log/mythtv/%programname%.%syslogtag:R,ERE,1,ZERO:\[([[:digit:]]{1,})\]--end%.log"

# Send all logging on local7 facility to mythtvFile (filename created according
# to the template specified, above), then discard (so the message is not also
# written to system other log files).
# This should catch any output from MythTV applications, assuming they are
# started with:
#   --syslog local7
local7.* ?mythtvFile
& ~

# Reset global directives to those specified in the main rsyslog.conf file
# Ensure the following values are specified (and agree with the main
# rsyslog.conf file) if you set MythTV-specific permissions at top.
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirOwner syslog
$DirGroup adm
$DirCreateMode 0755

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