Alex
Alex

Reputation: 1

Exclude specific error from syslog made by Python script subprocess in Debian

I have Python script, which use subprocess to run mosquitto.

Mosquitto is carrying out sucessfuly, but writes error in Syslog:

Warning: Unable to locate configuration directory, default config not loaded.

This error caused by Mosquitto bug and may be excluded only by version update, but that is not possible for me.

Are any possible ways to remove just that error from log?

As I understand that is possible to send stderr in null, but I don't know how to process stderr.

That is example, how I run mosquitto.

try:
    subprocess.check_call(args)
except subprocess.CalledProcessError as e:
    sys.stderr.write(
    'ERROR: call to mosquitto_pub failed with error code {}\n'.format(e.returncode))

Upvotes: 0

Views: 59

Answers (1)

Tristan Grimaux
Tristan Grimaux

Reputation: 11

Had the same problem, ended up adding a file /etc/rsyslog.d/publoop.conf

with this content

if ($programname contains "publoop") then {
   action(type="omfile" file="/dev/null")
   stop
}

Upvotes: 1

Related Questions