我需要将spring应用程序的log4j2消息发送到Azure Event Hub。我正在尝试在log4j2-spring.xml
文件中配置一个追加程序以使用此项目https://github.com/rahoogan/log4j-eventhub-appender
喜欢
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="LOG_PATTERN_CONSOLE">
%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${hostName} --- [%15.15t] %-40.40c{1.} : %m%n%ex
</Property>
</Properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="${LOG_PATTERN_CONSOLE}"/>
</Console>
<Appender name="AzureAppender" type="com.rahoogan.log4j.EventHubRestAppender">
</Appender>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="ConsoleAppender" />
<AppenderRef ref="AzureAppender" />
</Root>
</Loggers>
</Configuration>
当我使用spring-boot
构建项目时,出现以下错误:
main ERROR Appenders contains an invalid element or attribute "Appender"
main ERROR Unable to locate appender "AzureAppender" for logger config "root"```
What am I doing wrong? Could you explain me how to add this as an appender/another approach that would work?
I expected the XML to load the AzureAppender as a valid appender, but I'm getting an error because the attribute "Appender" is not valid