Sickbeard logging to syslog (Fedora & systemd)

Get help with Sick Beard and report/discuss bugs

Sickbeard logging to syslog (Fedora & systemd)

Postby wirerydr » Tue Dec 18, 2012 10:55 am

Hello all;

(Sorry for the long-winded description. My actual workaround is at the bottom of this post.)

First let me say that I haven't done any serious programming in over a decade, so my ability to understand Sickbeard's code is VERY rusty. My apologies if I draw any inaccurate conclusions.

I'm not sure if it's always behaved this way or not, but Sickbeard clutters up my syslog (in my case on Fedora 17, /var/log/messages) with all logging messages from INFO upward (no DEBUG messages appear to be logged). This duplicates the output being sent to Sickbeard's file-based rotating logfiles, and is obviously both redundant and messy.

Being unfamiliar with Sickbeard's code, and finding absolutely nothing pertinent on Google regarding Sickbeard and syslog output, it took me forever to track this down.

Sickbeard's logging initializer seems sets things up to log all INFO-and-up messages to sys.stderr console output. On (at least) Fedora 17, the default behaviour of systemd-journal is to echo any service's console output to syslog, resulting in all Sickbeard's logging output getting duplicated into general syslog. The specific chunk of code that (I think) is doing this is:

In: sickbeard/logger.py
Code: Select all
 def initLogging(self, consoleLogging=True):

        self.log_file = os.path.join(sickbeard.LOG_DIR, self.log_file)

        self.cur_handler = self._config_handler()

        logging.getLogger('sickbeard').addHandler(self.cur_handler)

        # define a Handler which writes INFO messages or higher to the sys.stderr
        if consoleLogging:
            console = logging.StreamHandler()

            console.setLevel(logging.INFO)

            # set a format which is simpler for console use
            console.setFormatter(logging.Formatter('%(asctime)s %(levelname)s::%(message)s', '%H:%M:%S'))

            # add the handler to the root logger
            logging.getLogger('sickbeard').addHandler(console)


My meagre coding skills failed to find any way to disable console-logging output within Sickbeard via configuration. This method's definition provides a default value for the consoleLogging argument of True, and the method's only invocation seems to not override the default. I'm unsure why console-logging would be a required behaviour, but I'm assuming it's desired in some scenarios.

Workaround

My workaround is to update my Sickbeard's systemd service unit file to redirect stderr console output to /dev/null, suppressing it before it can get echoed to syslog. This only affects Sickbeard; other services are unaffected.

In the [Service] section of your Sickbeard service unit file, add the following line: StandardError=null . For example, my full service unit file looks like this:

Code: Select all
[Unit]
Description=Internet PVR for your TV Shows

[Service]
ExecStart=/usr/bin/python /home/sabnzbd/sickbeard/SickBeard.py
Type=simple
User=sabnzbd
Group=sabnzbd
StandardError=null

[Install]
WantedBy=multi-user.target


Cheers;

WireRydr
Last edited by wirerydr on Tue Dec 18, 2012 11:13 am, edited 5 times in total.
wirerydr
 
Posts: 4
Joined: Mon May 30, 2011 1:13 pm

Re: Sickbeard logging to syslog (Fedora & systemd)

Postby rascalli » Tue Dec 18, 2012 11:10 am

SB should not write to the syslog , but to it's own log
You can then set this log to a certain size & to rotate

That way it can stay as small as you like
NL newsserver starting €44,40 a year

Image

Hope you will use my refereal link
rascalli
 
Posts: 4896
Joined: Tue Aug 10, 2010 2:26 pm

Re: Sickbeard logging to syslog (Fedora & systemd)

Postby wirerydr » Tue Dec 18, 2012 11:21 am

Thanks, rascalli.

I semi-agree - SB's not explicitly writing to syslog; but it is writing to console stderr, at least according to the code snippet in my o.p. However It's the default behaviour of Fedora's systemd-journal that's causing console stderr to ultimately be echoed to syslog.

This probably isn't a bug per-se; rather's its a "gotcha" that folks using systemd need to be aware of.

What would be ideal would be to make SB's sys.stderr console logging a configurable behaviour, so people wouldnt have to mess around with system-level changes. Unless, of-course, I'm missing something and turning off console output would break something.

Thanks again;

WireRydr
wirerydr
 
Posts: 4
Joined: Mon May 30, 2011 1:13 pm


Return to Support / Bug Reports

Who is online

Users browsing this forum: Bing [Bot] and 7 guests