开发者

How do you change the level translation for log4j SyslogAppender?

开发者 https://www.devze.com 2023-03-14 16:38 出处:网络
By default, the FATAL level in log4j will map to emergen开发者_开发技巧cy in Syslog.Because of IT syslog usage requirements in our corporation, I need FATAL to map to syslog alert instead.

By default, the FATAL level in log4j will map to emergen开发者_开发技巧cy in Syslog. Because of IT syslog usage requirements in our corporation, I need FATAL to map to syslog alert instead.

Does anyone know of a simple way to accomplish this?


There is guidance here on how to do this by overriding the append method in the SyslogAppender class. afai can see the mappings in log4j are hard-coded.

If you use logger.fatal(), the standard log4j syslog appender will log this message with the highest syslog severity, which is level 0, "emerg". This level is usually reserved for the most urgent operating system related messages and on most Unix systems will print the message on the terminal session of every logged in user. For most applications, this is probably not what you want. If an application encounters a fatal error, it should log the message as a lower level like "critical", level 2. You can do this by implementing an appender which overrides the "append" method.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号