2017-05-05 84 views
0

我是在使用log4j2.xml根据类别路由日志消息之后。 我发现下面的链接,但不知道如何实现它 https://docs.mulesoft.com/mule-user-guide/v/3.8/logger-component-reference#configuring-custom-logging-settings如何使用log4j2.xml根据类别路由日志消息

有人可以请提供一个示例配置log4j2.xml。

下面是我的log4j2.xml配置

<Appenders> 
    <RollingFile name="file" 
fileName="${sys:mule.home}${sys:file.separator}logs 
${sys:file.separator}splunktest.log" 
      filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}splunktest-%i.log"> 
     <PatternLayout pattern="%d [%t] %-5p %c - %m%n" /> 
     <SizeBasedTriggeringPolicy size="10 MB" /> 
     <DefaultRolloverStrategy max="10"/> 
    </RollingFile> 
    <RollingFile name="splunk" 
fileName="${sys:mule.home}${sys:file.separator}logs 
${sys:file.separator}ForSplunk.log" 
      filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}ForSplunk-%i.log"> 
     <PatternLayout pattern="%d [%t] %-5p %c - %m%n" /> 
     <SizeBasedTriggeringPolicy size="10 MB" /> 
     <DefaultRolloverStrategy max="10"/> 
    </RollingFile> 
</Appenders> 

<AsyncRoot level="INFO"> 
     <AppenderRef ref="file" /> 
    </AsyncRoot> 

    <AsyncLogger name="test" level="INFO" category="splunk"> 
     <AppenderRef ref="splunk" /> 
    </AsyncLogger> 

记录仪输出类APP和Splunk的。在这种情况下,我希望类别splunk记录器消息转到文件ForSplunk.log。

  • [[splunktest] .HTTP_Listener_Configuration.worker.01] APP:开始 记录器
    • [[splunktest] .HTTP_Listener_Configuration.worker.01]的Splunk: 结束记录器

回答

0

@ user3366906我们在我们的项目中使用了日志类别。

您需要为类别字段指定一些值,并且应该在cloudHub日志记录中指定相同的值。

+0

我已经从我的log4j2.xml中添加了配置 – user3366906