What version of Log4j2 are you using? You can raise a JIRA ticket here: https://issues.apache.org/jira/browse/LOG4J2
(Shameless plug) Every java main() method deserves http://picocli.info > On Nov 28, 2017, at 18:08, Laurent Hasson <l...@capsicohealth.com> wrote: > > Hello, > > Sorry for asking, but where could I log a JIRA ticket? I have a very simple > test case: > > public class Log4JTest > { > protected static final Logger Log = > LogManager.getLogger(Log4JTest.class.getName()); > protected static final int MAX = 10; > public static void main(String[] args) > { > for (int i = 0; i < MAX; ++i) > { > for (int j = 0; j < MAX; ++j) > { > Log.fatal("Fatal i=" + i + "; j=" + j + ";"); > Log.error("Error i=" + i + "; j=" + j + ";"); > Log.warn("Warn i=" + i + "; j=" + j + ";"); > Log.info("Info i=" + i + "; j=" + j + ";"); > Log.debug("Debug i=" + i + "; j=" + j + ";"); > Log.trace("Trace i=" + i + "; j=" + j + ";"); > } > } > Log.info("DONE."); > } > } > > And a very simple log4j2.xml > > <?xml version="1.0" encoding="UTF-8"?> > <Configuration status="info"> > <Appenders> > <Console name="Console" target="SYSTEM_OUT" > > <PatternLayout> > <pattern>%d{MMdd.HHmmss.SSS}#%-3t > %level{length=1} %15.15c{1}| %m%ex{20}%n</pattern> > </PatternLayout> > </Console> > </Appenders> > <Loggers> > <AsyncRoot level="debug"> > <AppenderRef ref="Console" /> > </AsyncRoot> > </Loggers> > </Configuration> > > And I can observe that lots of messages are either lost of are not flushed. > This happens even if I change the console to go to a file. > > Thank you, > > Laurent Hasson > Co-Founder and CTO > CapsicoHealth Inc. > > > Research has shown that capsaicin, the substance that gives hot red peppers > (or chilies) their kick, and boosts our metabolism, keeps immature fat cells > from developing into full-fledged ones. And a recent study found that a > compound in some sweet peppers (called CH-19 Sweet), which resembles > capsaicin, provides similar positive metabolic effects. > > -----Original Message----- > From: Remko Popma [mailto:remko.po...@gmail.com] > Sent: Thursday, November 23, 2017 17:36 > To: Log4J Users List <log4j-user@logging.apache.org> > Subject: Re: Flushing async appenders > > 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 <l...@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 >> >> >> > ТÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÐÐ¥FòVç7V'67&–&RÂRÖ֖âÆösF¢×W6W"×Vç7V'67&–&TÆövv–æræ6†Ræ÷&pФf÷"FF—F–öæÂ6öÖÖæG2ÂRÖ֖âÆösF¢×W6W"Ö†VÇÆövv–æræ6†Ræ÷&pÐ >