[logback-user] Logback not rolling
nicofari
nicola.farina at info-line.it
Fri Sep 14 17:32:46 CEST 2018
Hi all
Sorry I know it's an already asked question, but I can't figure out how to
configure logback to solve the problem.
Here is my config:
tomcat 7 under windows server 2012
logback 1.1.7
slf4j 1.7.21
java 7
logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds" debug="true">
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs\logback.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>logs\logback.%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>20</maxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>10MB</maxFileSize>
</triggeringPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%date [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="it.infoline" level="WARN" />
<logger name="org.flywaydb" level="OFF" />
<logger name="it.infoline.ouverture.data.LogonDatabase" level="DEBUG" />
<root level="WARN">
<appender-ref ref="FILE" />
</root>
</configuration>
Enabling logback debug I've seen that the root cause is the renaming:
16:05:55,728 |-INFO in c.q.l.co.rolling.helper.RenameUtil - Renaming file
[logs\logback.log] to [logs\logback.1.log]
16:05:55,728 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Failed to rename
file [logs\logback.log] as [logs\logback.1.log].
16:05:55,729 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Please consider
leaving the [file] option of RollingFileAppender empty.
16:05:55,729 |-WARN in c.q.l.co.rolling.helper.RenameUtil - See also
http://logback.qos.ch/codes.html#renamingError
The solution in the link (http://logback.qos.ch/codes.html#renamingError)
doesn't work with FixedWindowRollingPolicy if I understand well, right ?
So I tried something like this:
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>C:\Infoline\WebAppConfig\log.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>1KB</maxFileSize>
</triggeringPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>${HOSTNAME} %date [%thread] %-5level %logger >%X{ILSID}< -
%msg%n</pattern>
</encoder>
</appender>
With this configuration I didn't understand where the log will go.
Without file option, how can I tell logback which file to use?
Sorry for the trivial question but it seems I can't find a solution myself
thanks in advance
Nicola
--
Sent from: http://logback.10977.n7.nabble.com/Users-f3.html
More information about the logback-user
mailing list