I have such logback.xmp conf:
<configuration scan="true" scanPeriod="10 seconds" >
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>[%d{HH:mm:ss}] [%level] - %message%n%xException</pattern>
</encoder>
</appender>
<logger name="play" level="WARN"/>
<logger name="application" level="DEBUG"/>
<logger name="org.jdbcdslog.ConnectionLogger" level="OFF"/> <!-- Won' log connections -->
<logger name="org.jdbcdslog.StatementLogger" level="INFO"/> <!-- Will log all statements -->
<logger name="org.jdbcdslog.ResultSetLogger" level="OFF"/> <!-- Won' log result sets -->
<root level="WARN">
<appender-ref ref="FILE"/>
</root>
</configuration>
Every time I restart my prog it creates new log file, but in my way I want to continue write logs into old one. So, what is the problem?
I think you need to use the append
property.
Append to or truncate the file? The default value for this variable is true, meaning that by default a FileAppender will append to an existing file and not truncate it.
For example:
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home:-.}/logs/application.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>[%d{HH:mm:ss}] [%level] - %message%n%xException</pattern>
</encoder>
<append>true</append>
</appender>
However, since (according to the javadoc ... and the current version's source code) the append
property defaults to true
, it is unclear why you would need to do this1.
Note that setting prudent
to true
also sets append
to true
.
1 - Unless ... perhaps ... you are running into a Windows file locking issue?