引入异步性质后,logback.xml不起作用

时间:2019-07-18 05:20:53

标签: java asynchronous logback slf4j vert.x

我在resources文件夹中有一个logback.xml,如果我不添加异步处理程序,它将正常工作。 因为我们是一个实时应用,竞争激烈。我们希望记录器是异步的。 我添加异步代码

后,记录器不会提供任何日志

下面的xml可以正常工作-

<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="com.aexp.csrt.qs.cb.resources.MyLogHandler" />
    </encoder>
  </appender>
  <root level="info">
    <appender-ref ref="ASYNC" />
  </root>
  <logger name="com.aexp.csrt.qs.cb" level="info" />
</configuration>

The below xml stops giving log output . 
observe that i have added a asyc appender
<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="com.aexp.csrt.qs.cb.resources.MyLogHandler" />
    </encoder>
  </appender>
   <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="STDOUT" />
  </appender>

  <root level="info">
    <appender-ref ref="ASYNC" />
  </root>
  <logger name="com.aexp.csrt.qs.cb" level="info" />
</configuration>

Below xml works fine - 
<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="com.aexp.csrt.qs.cb.resources.MyLogHandler" />
    </encoder>
  </appender>
  <root level="info">
    <appender-ref ref="ASYNC" />
  </root>
  <logger name="com.aexp.csrt.qs.cb" level="info" />
</configuration>

The below xml stops giving log output . 
observe that i have added a asyc appender
<configuration>
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
      <layout class="com.aexp.csrt.qs.cb.resources.MyLogHandler" />
    </encoder>
  </appender>
   <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="STDOUT" />
  </appender>

  <root level="info">
    <appender-ref ref="ASYNC" />
  </root>
  <logger name="com.aexp.csrt.qs.cb" level="info" />
</configuration>

我希望记录器异步工作。我目前在sl4j中使用vertx

0 个答案:

没有答案