properties文件的Syslog的LoggerFields

properties文件的Syslog的LoggerFields

本文介绍了带有log4j2.properties文件的Syslog的LoggerFields的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些log4j2 syslog示例,用于使用键,值为xml添加优先级,但是对于log4j.properties文件,我们无法为值添加=符号,我也没有任何示例来设置LoggerFields以设置优先级带有RFS5454格式.

There are examples for log4j2 syslog for adding priority to log with xml using key, value but with log4j.properties files we can't add = symbol to value and I haven't any example to set LoggerFields for setting priority with RFS5454 format.

这是关闭的 Syslog的LoggerFields(输出日志优先级)和堆栈跟踪)

以下各项均不适用于LoggerField:

None of the below works for LoggerField:

appender.sumo_syslog.loggerFields = {'key':'priority','value':'%p'}或者appender.sumo_syslog.loggerFields = [{'key':'priority','value':'%p'}]或者appender.sumo_syslog.loggerFields.keyValuePair = {'key':'优先级','value':'%p'}

appender.sumo_syslog.loggerFields={'key' : 'priority', 'value' : '%p'}orappender.sumo_syslog.loggerFields=[{'key' : 'priority', 'value' : '%p'}]orappender.sumo_syslog.loggerFields.keyValuePair={'key' : 'priority', 'value' : '%p'}

推荐答案

您可以使用以下方式:

appender.syslog.type = Syslog
appender.syslog.name = syslog
appender.syslog.facility = LOCAL0
appender.syslog.host = X.X.X.X
appender.syslog.appName = API-TEST
appender.syslog.enterpriseNumber = 18060
appender.syslog.port = 514
appender.syslog.newLine = true
appender.syslog.protocol = TCP
appender.syslog.format = RFC5424
appender.syslog.messageId = Audit
appender.syslog.id = system1
appender.syslog.mdcId = mdc
appender.syslog.layout.type = loggerFields
appender.syslog.layout.pairs.type = KeyValuePair
appender.syslog.layout.pairs.key = category
appender.syslog.layout.pairs.value = %c
appender.syslog.layout.pairs2.type = KeyValuePair
appender.syslog.layout.pairs2.key = message
appender.syslog.layout.pairs2.value = %m
appender.syslog.layout.pairs3.type = KeyValuePair
appender.syslog.layout.pairs3.key = exception
appender.syslog.layout.pairs3.value = %ex

这篇关于带有log4j2.properties文件的Syslog的LoggerFields的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:36