在log4j2的XML中配置附加程序将消息发送到Azure EventHub

时间:2019-03-25 09:51:42

标签: log4j2 azure-eventhub

我需要将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

0 个答案:

没有答案