我正在将应用程序作为 systemd 服务运行。应用程序按照 systemd 日志记录规则将其输出记录到 stdout - 在每条日志消息前面添加 <x>,其中 x 是优先级(日志级别)。
<6> this is info
<7> this is debug
<4> this is warning
Run Code Online (Sandbox Code Playgroud)
我想要的是仅将优先级 <= 6 存储到日志中,因为我在闪存盘上运行。我不想存储调试消息以及未用 <> 标记的消息/“垃圾”。
似乎不是问题 - MaxLevelStore=info。
但是 - 问题是写入 stdout 的“垃圾”默认标记为priority=6(信息),并且也存储在日志数据库内。我想要的是默认将其标记为调试(7),因此从以下输出:
<6> this is info
<7> this is debug
this is some trash
<4> this is warning
Run Code Online (Sandbox Code Playgroud)
...只会...
<6> this is info
<4> this is warning
Run Code Online (Sandbox Code Playgroud)
...存储到日志中。
在我拥有的所有文档中找不到这是否/如何可能。有人吗?
谢谢