You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Christian Wansart <ch...@openknowledge.de> on 2017/09/19 11:16:28 UTC
log4j2.xml won't get read
Hello,
I am working on a jax-rs project that uses log4j through slf4j-api and log4j-slf4j-impl. So far, I configured the logging pattern via Wildfly’s standalone.xml. But I want to have a project wide config file for logging.
I put a log4j2.xml in the resources folder, but when I run it, it just uses the pattern of the standalone.xml.
Here is my log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="MYLOG TEST %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
What am I missing? It seems that the file was not read? In the output in my IntelliJ IDEA IDE I just see the log messages in the format I set in the standalone.xml.
Best regards,
Christian
Re: log4j2.xml won't get read
Posted by Mikael Ståldal <mi...@apache.org>.
I don't know how Wildfly works, but maybe you should ask this question
to any support forum of Wildfly.
On 2017-09-19 13:16, Christian Wansart wrote:
> Hello,
>
> I am working on a jax-rs project that uses log4j through slf4j-api and log4j-slf4j-impl. So far, I configured the logging pattern via Wildfly’s standalone.xml. But I want to have a project wide config file for logging.
>
> I put a log4j2.xml in the resources folder, but when I run it, it just uses the pattern of the standalone.xml.
>
> Here is my log4j2.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
> <Appenders>
> <Console name="Console" target="SYSTEM_OUT">
> <PatternLayout pattern="MYLOG TEST %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
> </Console>
> </Appenders>
> <Loggers>
> <Root level="error">
> <AppenderRef ref="Console"/>
> </Root>
> </Loggers>
> </Configuration>
>
> What am I missing? It seems that the file was not read? In the output in my IntelliJ IDEA IDE I just see the log messages in the format I set in the standalone.xml.
>
> Best regards,
> Christian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: log4j2.xml won't get read
Posted by Christian Wansart <ch...@openknowledge.de>.
Hello,
it works when I use log4j.xml with this structure:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="ALL"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="MYLOG %d{HH:mm:ss,SSS} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
My guess is that this is the old log4j 1 syntax, but it is currently the only thing that works for Wildfly. I should ask the Wildfly community if there’s a way to enable Wildfly to recognize the new log4j2.xml.
Thank you!
Christian
Am 19.09.17, 13:16 schrieb "Christian Wansart" <ch...@openknowledge.de>:
Hello,
I am working on a jax-rs project that uses log4j through slf4j-api and log4j-slf4j-impl. So far, I configured the logging pattern via Wildfly’s standalone.xml. But I want to have a project wide config file for logging.
I put a log4j2.xml in the resources folder, but when I run it, it just uses the pattern of the standalone.xml.
Here is my log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="MYLOG TEST %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
What am I missing? It seems that the file was not read? In the output in my IntelliJ IDEA IDE I just see the log messages in the format I set in the standalone.xml.
Best regards,
Christian