Running my main application in Eclipse it is using the log4j2-test.xml
configuration, and not the log4j2.xml configuration.

src/main/resources/log4j2.xml
src/test/resources/log4j2-test.xml

I am not running a test application under src/test, but my main application
under src/main/
target/classes/log4j2.xml
target/test-classes/log4j2-test.xml

How do I avoid it using the log4j2-test.xml when running from Eclipse?

With a programmatic configuration it does not pick the log4j2-text.xml.

*My XML configuration:*
<?xml version="1.0" encoding="UTF-8"?>

<!-- Don't forget to set system property
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
    to make all loggers asynchronous. -->

<Configuration status="WARN">
    <Properties>
        <Property name="pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS}
[%level] %logger: %m%n" />
    </Properties>
    <Appenders>
        <!-- Async Loggers will auto-flush in batches, so switch off
immediateFlush. -->
        <RollingRandomAccessFile name="RollingRandomAccessFile"
fileName="${sys:user.home}/.app/app.log"
            filePattern="app-%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false" append="false">
            <PatternLayout>
                <Pattern>${pattern}</Pattern>
            </PatternLayout>
            <Policies>
                <OnStartupTriggeringPolicy />
            </Policies>
        </RollingRandomAccessFile>
    </Appenders>
    <Loggers>
        <Logger name="com.company" level="ERROR" includeLocation="false"
additivity="false">
            <AppenderRef ref="RollingRandomAccessFile" />
        </Logger>
        <Root level="WARN" includeLocation="false">
            <AppenderRef ref="RollingRandomAccessFile" />
        </Root>
    </Loggers>
</Configuration>


/Sverre

Reply via email to