I just started using log4j2. I am using it for multiple JVMs that use RMI. I have two problems.
I start up the rmiregistry as it's own executable using the same CLASSPATH as the application. It starts without any errors, but once an RMI client talks to it, rmiregistry outputs this error: ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath... But the log4j-core jar file is already in the CLASSPATH and if there was a problem, then why does the application not output this error as well?
I am using the RollingFile appender with OnStartupTriggeringPolicy and SizeBasedTriggeringPolicy. In theory at startup I should get logs like:
foo.log - active log
foo.log.1 - old log rolled if I already started it before
foo.log.2 - older log rolled if I already started it more than once
But instead when I start it the first time, it rolls a bunch of times, even though the size limit has not been reached and the active log is one that should have been rolled. In other words, I get this:
foo.log
foo.log.1
foo.log.2
foo.log.3 - active log
foo.log.4
Config file (log4j2.xml) contents:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<!-- ********** APPENDERS *********** -->
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d (%-4r) [%t] %-5p %c %x - %m%n"/>
</Console>
<RollingFile
name="FOO_OUT"
fileName="/foo/log/foo.log"
filePattern="/foo/log/foo.log.%i"
append="true">
<PatternLayout>
<Pattern>%d (%-4r) [%t] %-5p %c %x - %m%n</Pattern>
</PatternLayout>
<DefaultRolloverStrategy max="24" fileIndex="min"/>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB"/>
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<asyncLogger name="au.com" level="DEBUG">
<AppenderRef ref="FOO_OUT"/>
</asyncLogger>
<asyncRoot level="debug">
<AppenderRef ref="FOO_OUT"/>
</asyncRoot>
</Loggers>
</Configuration>
The CLASSPATH includes a lot of jars, but main ones related to lo4j2 are:
/foo/lib/slf4j/slf4j-api-1.7.21.jar
/foo/lib/slf4j/jcl-over-slf4j-1.7.21.jar
/foo/lib/slf4j/log4j-slf4j-impl-2.5.jar
/foo/lib/log4j2/log4j-core-2.5.jar
/foo/lib/log4j2/log4j-api-2.5.jar
/foo/lib/log4j2/disruptor-3.3.4.jar