I'm using Logback for logging. At the beginning of each line after the first line is a space. Any idea why?
Below is my 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>
This results in log output like the following (notice the first line doesn't have a a space):
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
Change the value of log.pattern to
"%d{yyyy/MM/dd HH:mm:ss.SSS} %-5level [%logger{0}] %msg%n%ex"
Note: there is no space between %n and %ex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With