【问题标题】:Exclude specific error from syslog made by Python script subprocess in Debian从 Debian 中的 Python 脚本子进程生成的 syslog 中排除特定错误
【发布时间】:2020-03-12 11:25:17
【问题描述】:

我有 Python 脚本,它使用子进程来运行 mosquitto。

Mosquitto 执行成功,但在 Syslog 中写入错误:

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

这个错误是由 Mosquitto bug 引起的,可能只能通过版本更新排除,但这对我来说是不可能的。

是否有任何可能的方法可以从日志中删除该错误?

据我了解,可以将标准错误发送为 null,但我不知道如何处理标准错误。

例如,我如何运行 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))

【问题讨论】:

    标签: python python-3.x error-handling debian


    【解决方案1】:

    遇到同样的问题,最后添加了一个文件/etc/rsyslog.d/publoop.conf

    有这个内容

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

    【讨论】:

      猜你喜欢
      • 2022-10-12
      • 2011-08-04
      • 2015-05-20
      • 2016-09-04
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 2012-12-03
      • 1970-01-01
      相关资源
      最近更新 更多