RE: Double logging after customizing module-log4j.xml

Jani Oksanen, modified 7 Years ago. New Member Posts: 12 Join Date: 8/29/17 Recent Posts
Hello.

​​​​​​​Im currently adding loggin options for my modules using (https://dev.liferay.com/de/develop/tutorials/-/knowledge_base/7-0/adjusting-module-logging) as guide. I have managed to change pattern for specific java package, but now I have problem that I get double logging to catalina.out Is there any way to disable logging for stock tomcat and instead use my custom module-log4j-ext.xml only?

module-log4j-ext.xml
<!--?xml version="1.0"?-->

<log4j:configuration   xmlns:log4j="http://jakarta.apache.org/log4j/">

&nbsp; &nbsp; <appender name="console"   class="org.apache.log4j.ConsoleAppender">
&nbsp; &nbsp; &nbsp; &nbsp; <param name="Target" value="System.out">
&nbsp; &nbsp; &nbsp; &nbsp; <layout class="org.apache.log4j.PatternLayout">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <param name="ConversionPattern"   value="%d{dd.MM.yyyy HH:mm:ss.SSS} %-5p [%t] [%C] &nbsp;%m%n">
&nbsp; &nbsp; &nbsp; &nbsp; </layout>
&nbsp; &nbsp; </appender>

&nbsp; &nbsp; <category name="foo.bar">
&nbsp; &nbsp; &nbsp; &nbsp; <priority value="DEBUG" />
&nbsp; &nbsp; &nbsp; &nbsp; <appender-ref ref="console" />
&nbsp; &nbsp; </category>
</log4j:configuration>
​​​​​​​catalina.out after previous modification
​​​​​​​23.10.2018 08:15:27.519 WARN &nbsp;[http-nio-8081-exec-3] [foo.bar.testClass] &nbsp;testLogging  &lt;-- Overridden logging
2018-10-23 08:15:27.519 WARN &nbsp;[http-nio-8081-exec-3][testClass] testLogging &lt;-- originaltomcat logging (Needs to be removed)
​​​​​​​
​​​​​​​Thanks for help in advance!
thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
Jani Oksanen

<category name="foo.bar">
&nbsp; &nbsp; <priority value="DEBUG" />
&nbsp; &nbsp; <appender-ref ref="console" />
</category>

Have you already tried setting the additivity to false?

<category name="foo.bar" additivity="false">
&nbsp; &nbsp; <priority value="DEBUG" />
&nbsp; &nbsp; <appender-ref ref="console" />
</category>