logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <remko.po...@gmail.com>
Subject Re: Flushing async appenders
Date Thu, 23 Nov 2017 22:35:47 GMT
That is strange: with the async appender (and also with async loggers),
Log4j2 should automatically flush the I/O buffer when the async queue is
empty...
You may have found an issue. Can you raise a JIRA ticket for this?

Meanwhile, you can add attribute  immediateFlush="true"  to your Rolling
file appender configuration. (See also
https://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender
)

On Thu, Nov 23, 2017 at 11:42 PM, Laurent Hasson <ldh@capsicohealth.com>
wrote:

> Hello all,
>
> I have the following configuration file using async appenders. It works
> well but I have one issue. During low-volume activity on my site, it seems
> that nothing is output to the file, so it's hard to see what's going on.
> Same issue happens while developing. But as soon as enough activity occurs,
> then the logs are flushed to the file as expected. I suspect there is a
> buffer somewhere that only gets flushed when it's full, and so during low
> activity, that may take a while. Is there a way to control that so that
> flushing happens more often, wither by sizing the buffer to be smaller, or
> maybe some timeout value, i.e., flush at least once every 5s?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="info">
>       <Properties>
>             <Property name="log-path">C:\Projects\TomcatDevServer\logs\</
> Property>
>             <Property name="now">${sys:startup}</Property>
>       </Properties>
>       <Appenders>
>             <RollingFile name="FILES" fileName="${log-path}/loga.log"
> filePattern="${log-path}/logs.${now}.%i.log.gz">
>                   <PatternLayout>
>                 <pattern>%d{MMdd.HHmmss.SSS}#%-3t %level{length=1}
> %15.15c{1}|  %m%ex{20}%n</pattern>
>                   </PatternLayout>
>                   <Policies>
>                         <SizeBasedTriggeringPolicy size="100 MB" />
>                   </Policies>
>                   <DefaultRolloverStrategy max="99999"
> compressionLevel="6"/>
>             </RollingFile>
>             <Async name="ASYNC">
>                   <AppenderRef ref="FILES" />
>             </Async>
>       </Appenders>
>       <Loggers>
>             <Root level="debug">
>                  <AppenderRef ref="ASYNC" />
>             </Root>
>       </Loggers>
> </Configuration>
>
>
> Thank you,
>
>
> Laurent Hasson
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message