【问题标题】:Sling logging configuration in EquinoxEquinox 中的 Sling 日志记录配置
【发布时间】:2015-08-21 11:02:38
【问题描述】:

我正在尝试在 Equinox 项目中使用 Apache Sling 日志记录。它工作正常,但我不能让 Sling 使用我的配置文件。我正在使用标准的 logback 配置 xml,它应该根据 Sling documentation 工作。但是无论我把配置文件放在哪里 Sling 就是不使用它。

我的logback配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%d{dd.MM.yyyy HH:mm:ss.SSS} *%level* [%thread] %logger %message%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="CONSOLE" />
  </root>
</configuration>

【问题讨论】:

  • 到目前为止,您尝试将 logback 配置文件放在哪些位置?
  • @Val 我尝试将配置文件放在/src/main/resources 中,这应该将其放在类路径和项目的根目录中。都没有用。
  • 您是否检查过该文件是否完全复制到您的可交付成果中?
  • @Val 是的,它被复制了。

标签: java osgi logback equinox sling


【解决方案1】:

我设法让 Sling 使用我的配置文件的唯一方法是将配置文件的位置作为 VM 参数传递,如下所示:-Dorg.apache.sling.commons.log.configurationFile=/path/to/logbackconfigfile,其中路径是配置文件位置的完整路径。不幸的是,我还没有设法让它与相对路径一起工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-02
    • 2013-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 2012-06-24
    • 1970-01-01
    相关资源
    最近更新 更多