我正在使用logback 1.0.0,我的配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!--Daily rolling file appender -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>logs\motivosity_logback.log</File> <!-- make sure you have permissions on this file -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<FileNamePattern>logs\logFile.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>50MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.myapp">
<level value="debug" />
</logger>
<logger name="org.ocpsoft.rewrite.faces">
<level value="debug" />
</logger>
<logger name="org.springframework.security.web.authentication">
<level value="debug" />
</logger>
<logger name="org.apache">
<level value="info" />
</logger>
<root>
<level value="info" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
它在本地运行良好,但在我打开主页时在 cloudbees 上运行
我在 papertrailapp 中看不到任何日志
我使用日志如下:
private static Logger log = LoggerFactory.getLogger(MyBean.class);
if (log.isDebugEnabled()) {
log.debug("INIT MyBean");
}
请告知为什么它不起作用。
更新:
- 标准系统输出工作正常:
System.out.println("INIT MyBean");
我想登录的类在 com.myapp.web.controllers 包中,我为com.myapp配置了记录器,如下所示:
但是当我尝试 sysout
System.out.println("######## DEBUG ENABLED: " + log.isDebugEnabled());
时它打印错误,这意味着没有为这个类启用调试,这很奇怪。
- 我尝试过的另一件事
log.info("@PostConstruct MyBean");
并且效果很好,我尝试将根日志记录级别更改为调试,但仍然只记录信息。