简体   繁体   English

Logback 只会将消息记录到 syslog 一次

[英]Logback will only log a message to syslog once

I've tried several examples of using logback to write to syslog, but the only that I've found that works is this JavaCodeGeeks example .我尝试了几个使用 logback 写入 syslog 的示例,但我发现唯一有效的是这个JavaCodeGeeks 示例 It writes a message to syslog, but it only writes a message once no matter how many times I run the code.它会向 syslog 写入一条消息,但无论我运行多少次代码,它都只会写入一次消息。 If I change the message it will write it to syslog, but only once.如果我更改消息,它会将其写入系统日志,但只会写入一次。

I'm on Ubuntu 19.10.我在 Ubuntu 19.10 上。 I've uncommented the following four lines from my /etc/rsyslog.conf and restarted:我已从 /etc/rsyslog.conf 中取消注释以下四行并重新启动:

# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
module(load="imtcp")
input(type="imtcp" port="514")

The only change I made to the javacodegeeks code is to comment out the remote appender in logback.xml .我对 javacodegeeks 代码所做的唯一更改是注释掉logback.xml中的远程附加程序。 It only logs to the localhost syslog.它只记录到本地主机系统日志。

What causes this weird behavior?是什么导致了这种奇怪的行为?

To log all messages you have to set要记录所有消息,您必须设置

$RepeatedMsgReduction off

in /etc/rsyslog.conf and restart rsyslog./etc/rsyslog.conf中并重新启动 rsyslog。

https://www.rsyslog.com/doc/v8-stable/configuration/action/rsconf1_repeatedmsgreduction.html https://www.rsyslog.com/doc/v8-stable/configuration/action/rsconf1_repeatedmsgreduction.html

The default was on in Ubuntu 19.10.在 Ubuntu 19.10 中默认on

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM