Sometimes the login does not write to the log file and sometimes it does not collapse the log file

Sometimes, when I run a java application, logback refuses to write anything to my log file. Sometimes he also refuses to roll the log file at midnight (or at the first logging event after midnight), which leads to logging events being lost in the void. When I look at my main log file, when logbacks failed to collapse the log, it will have a time like 23:59 with yesterday's date and any registration applications after this time will be irretrievably lost. I have a pretty simple configuration file and it looks correct. This, of course, should be correct, since it works most of the time.

Here is my configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <!--See http://logback.qos.ch/manual/appenders.html#RollingFileAppender-->
    <!--and http://logback.qos.ch/manual/appenders.html#TimeBasedRollingPolicy-->
    <!--for further documentation-->
    <append>true</append>
    <File>aggregator.log</File>
    <encoder>
        <!-- was: %d{yyyy-MM-dd HH:mm:ss}%5p [%t] (%F:%L) - %msg%n -->
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] \(%class{25}:%line\) - %msg%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <!-- By setting the name to .gz here, we get free compression. -->
      <fileNamePattern>aggregator.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
    </rollingPolicy>
  </appender>
  <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] \(%class{25}:%line\) - %msg%n</pattern>
    </encoder>
  </appender>
  <root level="DEBUG">
    <appender-ref ref="file"/>
    <appender-ref ref="console"/>
  </root>
</configuration>

, , . - , , ? , STDOUT STDERR /dev/null ( linux, btw).

+3
2

, . , .policy, . , , , , . , , logback .

0

, <configuration debug="true"> stdout. , - .

+9

Source: https://habr.com/ru/post/1761522/


All Articles