In my application currently I am using the log4j for log. All the logs are getting written in to same log file. there is one common log file, where some others application also used write the log.
Lets assume i have aap.log and common.log. I want that all the log will get in app.log file but for some specific class log will get in common.log.
My log4j config is as below for app.log
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${home}/logs/app.log</File>
<encoder>
<pattern>%d{MM.dd HH:mm:ss.SSS} [%2.2t][%c{1}.%M] %-5p - %m%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<maxIndex>20</maxIndex>
<FileNamePattern>${home}/logs/app.log.%i</FileNamePattern>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>25MB</MaxFileSize>
</triggeringPolicy>
</appender>
I don't want to create a new appender here for the common.log or addadditivity="false for that class. I want to use one CustomUtility class to write the log in to common.log instead of configuring it from log4.xml.
How can i write the log in same common.log file so other applications data or mine will not get messed up.