Excessive "-INFO...RenameUtil - Renaming file..." in Jetty8 stderrrout with Logback RequestLogImpl

StackOverflow https://stackoverflow.com/questions/16366949

  •  14-04-2022
  •  | 
  •  

Question

My app runs in Jetty8 and is leveraging Logback's RequestLogImpl (which is just great, by the way). Recently we discovered that if logback has a problem rolling over files, the logging message that would have alerted us to that appears nowhere because we had not configured Jetty to redirect its stderrout to any log file. My current release corrected that problem, but now I notice an excessive volume of INFO messages from logback in the jetty stderrout file like

06:32:14,893 |-INFO in c.q.l.co.rolling.helper.RenameUtil - Renaming file [/data/logs/md-stage-app4.dev.mgg.request.3.log] to [/data/logs/md-stage-app4.dev.mgg.request.4.log]

I only really care about these messages if the rename failed or something, which these messages come out as WARN. How can I get the logback stuff to just log at WARN and above into the jetty stderrout logfile?

My app itself does, indeed, <root level="info"> the root logger.

etc/jetty.xml has the following excerpt:

<!-- Logback Access Log implementation -->
<Ref id="RequestLog">
  <Set name="requestLog">
    <New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl">
      <Set name="fileName">etc/logbackAccess.xml</Set>
    </New>
  </Set>
</Ref>

etc/logbackAccess.xml is:

<configuration>
  <!-- always a good activate OnConsoleStatusListener -->
  <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

  <appender name="SIZE_ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <File>/data/logs/md-app3.request.log</File>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>/data/logs/md-app3.request.%i.log</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>5</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>1MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%h %l %u [%t] "%r" %s %b%n%fullRequest%n</pattern>
    </encoder>
  </appender>

  <appender-ref ref="SIZE_ROLLING" />
</configuration>
Était-ce utile?

La solution

The status messages are printed because of the line

<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

in logback-access.xml (etc/logbackAccess.xml in your case). By adapting OnConsoleStatusListener and OnPrintStreamStatusListenerBase, you should be able able to create a custom StatusListener which prints status messages except INFO messages originating at RenameUtil.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top