In our project, currently we have a main portal-log4j.xml and in our project we need to override it using portal-log4j-ext.xml In the portal-log4j.xml, we have all logging being done to the console by default.
<root>
<priority value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
In the overridden portal-log4j-ext.xml file, we have the following code :
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="maxFileSize" value="10000kb" />
<param name="maxBackupIndex" value="20" />
<param name="file" value="D:/myLogFile.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%C{1}] %x: %m%n"/>
</layout>
</appender>
<logger name="com.company.layoutimporter">
<level value="DEBUG" />
<appender-ref ref="FILE" />
</logger>
As you can see, I am able to write to a file, but its logging in the console as well. How can we override this default behaviour so that I can log my package specific messages only to the particular log file (and not to console).
Thanks in advance !
found a solution myself.. had to just add additivity="false" to the logger tag.
This will basically skip the logging again by the parent tags.
More info : Additivity - What and Why ?