我正在使用 Logback 进行日志记录。在第一行之后的每一行的开头是一个空格。知道为什么吗?
下面是我的 logback.xml:
<?xml version="1.0" encoding="utf-8"?>
<configuration debug="true">
<property name="log.pattern" value="%d{yyyy/MM/dd HH:mm:ss.SSS} %-5level [%logger{0}] %msg%n %ex"/>
<property name="log.file.prefix" value="${app.home}/var/log/${app.name}"/>
<appender name="DEFAULT" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.file.prefix}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.file.prefix}.%d{yyyyMMdd}.%i.log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>500MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<Pattern>${log.pattern}</Pattern>
</encoder>
</appender>
<!-- info for everything else -->
<root level="info">
<appender-ref ref="DEFAULT"/>
</root>
</configuration>
这导致日志输出如下(注意第一行没有空格):
2012/02/06 13:34:09.875 INFO [BrokerService] Using Persistence Adapter: MemoryPersistenceAdapter
2012/02/06 13:34:09.875 INFO [BrokerService] ActiveMQ 5.3.1 JMS Message Broker (localhost) is starting
2012/02/06 13:34:09.875 INFO [BrokerService] For help or more information please see: http://activemq.apache.org/
2012/02/06 13:34:09.953 INFO [ManagementContext] JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
2012/02/06 13:34:10.328 INFO [BrokerService] ActiveMQ JMS Message Broker (localhost, ID:NZucker-NYL-3937-1328553250062-0:0) started
2012/02/06 13:34:10.343 INFO [TransportConnector] Connector vm://localhost Started