0

我开始尝试使用 Camunda 引擎,并注意到它绕过了我的应用程序的日志并将所有内容写入标准输出(或标准错误?)。我怎样才能让它像其他所有图书馆一样好用?

就日志记录而言,应用程序具有以下依赖项(在 中build.gradle):

// Replaced with SLF4j below.  Make sure no libraries pull this as a dependency.
configurations.all {
    exclude group: 'commons-logging'
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.12'
    compile 'ch.qos.logback:logback-classic:1.1.3'
    // Replaces Apache Commons Logging with SLF4j.
    compile 'org.slf4j:jcl-over-slf4j:1.7.12'
}

因此,通过 SLF4j 或 Commons Logging 进行日志记录的库就可以了。但卡蒙达显然不得不发明另一个轮子……

4

1 回答 1

1

原来不是另一个轮子,而是java.util.logging。也可以使用以下 JAR 将其重定向到 SLF4j:

    compile 'org.slf4j:jul-to-slf4j:1.7.12'

但是,需要显式安装此桥接器(Java 代码):

    SLF4JBridgeHandler.removeHandlersForRootLogger ();
    SLF4JBridgeHandler.install ();

出于性能原因,最好将其包含在 Logback 配置中:

  <!-- For java.util.logging bridging; important for Camunda! -->
  <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
    <resetJUL>true</resetJUL>
  </contextListener>
于 2015-06-10T11:25:52.863 回答