Karaf 4.2 Syslog配置Log4j2

时间:2019-07-16 09:28:37

标签: osgi log4j2 apache-karaf syslog

我正在尝试配置Karaf 4.2.3的附加程序syslog,但是我的rsyslog服务器中什么也没收到。

该配置不会在Karaf端以及我运行时触发任何错误 log:getlog:display supervision我得到了配置的记录器的日志。

我尝试在服务组合7.0.1上使用log4j配置,并在rsyslog服务器中获取日志...

这是我的实际配置


# Common pattern layout for appenders
log4j2.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
log4j2.out.pattern = \u001b[90m%d{HH:mm:ss\.SSS}\u001b[0m %highlight{%-5level}{FATAL=${color.fatal}, ERROR=${color.error}, WARN=${color.warn}, INFO=${color.info}, DEBUG=${color.debug}, TRACE=${color.trace}} \u001b[90m[%t]\u001b[0m %msg%n%throwable


# Root logger
log4j2.rootLogger.level = INFO
# uncomment to use asynchronous loggers, which require mvn:com.lmax/disruptor/3.3.2 library
#log4j2.rootLogger.type = asyncRoot
#log4j2.rootLogger.includeLocation = false
log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile
log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi
log4j2.rootLogger.appenderRef.Console.ref = Console
log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter
log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.console:-OFF}

# Loggers configuration

# SSHD logger
log4j2.logger.sshd.name = org.apache.sshd
log4j2.logger.sshd.level = INFO

# Spifly logger
log4j2.logger.spifly.name = org.apache.aries.spifly
log4j2.logger.spifly.level = WARN

# Security audit logger
log4j2.logger.audit.name = audit
log4j2.logger.audit.level = TRACE
log4j2.logger.audit.additivity = false
log4j2.logger.audit.appenderRef.AuditRollingFile.ref = AuditRollingFile


log4j2.logger.syslog.name = supervision
log4j2.logger.syslog.level = INFO

log4j2.logger.security.name = security
log4j2.logger.security.level = INFO

# Appenders configuration

# Console appender not used by default (see log4j2.rootLogger.appenderRefs)
log4j2.appender.console.type = Console
log4j2.appender.console.name = Console
log4j2.appender.console.layout.type = PatternLayout
log4j2.appender.console.layout.pattern = ${log4j2.out.pattern}

# Rolling file appender
log4j2.appender.rolling.type = RollingRandomAccessFile
log4j2.appender.rolling.name = RollingFile
log4j2.appender.rolling.fileName = ${karaf.log}/karaf.log
log4j2.appender.rolling.filePattern = ${karaf.log}/karaf.log.%i
# uncomment to not force a disk flush
#log4j2.appender.rolling.immediateFlush = false
log4j2.appender.rolling.append = true
log4j2.appender.rolling.layout.type = PatternLayout
log4j2.appender.rolling.layout.pattern = ${log4j2.pattern}
log4j2.appender.rolling.policies.type = Policies
log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.rolling.policies.size.size = 16MB

# Audit file appender
log4j2.appender.audit.type = RollingRandomAccessFile
log4j2.appender.audit.name = AuditRollingFile
log4j2.appender.audit.fileName = ${karaf.log}/security.log
log4j2.appender.audit.filePattern = ${karaf.log}/security-%i.log
log4j2.appender.audit.append = true
log4j2.appender.audit.layout.type = PatternLayout
log4j2.appender.audit.layout.pattern = %m%n
log4j2.appender.audit.policies.type = Policies
log4j2.appender.audit.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.audit.policies.size.size = 8MB

# OSGi appender
log4j2.appender.osgi.type = PaxOsgi
log4j2.appender.osgi.name = PaxOsgi
log4j2.appender.osgi.filter = *

# help with identification of maven-related problems with pax-url-aether
#log4j2.logger.aether.name = shaded.org.eclipse.aether
#log4j2.logger.aether.level = TRACE
#log4j2.logger.http-headers.name = shaded.org.apache.http.headers
#log4j2.logger.http-headers.level = DEBUG
#log4j2.logger.maven.name = org.ops4j.pax.url.mvn
#log4j2.logger.maven.level = TRACE

log4j2.appender.security.type = Syslog
log4j2.appender.security.name = security
log4j2.appender.security.facility = LOCAL0 
log4j2.appender.security.host = 127.0.0.1
log4j2.appender.security.appName = send


log4j2.appender.syslog.type = Syslog
log4j2.appender.syslog.name = supervision
log4j2.appender.syslog.facility = LOCAL0 
log4j2.appender.syslog.host = 127.0.0.1
log4j2.appender.syslog.appName = send
#log4j2.appender.syslog.advertise = true
log4j2.appender.syslog.newLine = true
log4j2.appender.syslog.includeMDC = true
log4j2.appender.syslog.messageId = supervision
log4j2.appender.syslog.mdcId = mdc
log4j2.appender.syslog.format = RFC5424
log4j2.appender.syslog.immediateFlush = true 
log4j2.appender.syslog.enterpriseNumber = 18060
log4j2.appender.syslog.layout.type = loggerFields
log4j2.appender.syslog.layout.pairs.type = KeyValuePair
log4j2.appender.syslog.layout.pairs.key = category
log4j2.appender.syslog.layout.pairs.value = %c
log4j2.appender.syslog.layout.pairs2.type = KeyValuePair
log4j2.appender.syslog.layout.pairs2.key = message
log4j2.appender.syslog.layout.pairs2.value = %m
log4j2.appender.syslog.layout.pairs3.type = KeyValuePair
log4j2.appender.syslog.layout.pairs3.key = exception
log4j2.appender.syslog.layout.pairs3.value = %ex


我希望日志将发送到rsyslog服务器。

谢谢!

0 个答案:

没有答案