Issues with bridge API while migrating to log4j 2
"Kudethur, Pavithra (Enterprise)" <[email protected]>
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <CO6PR16MB41301974D97836AB4CEF9F01E63A9@CO6PR16MB4130.namprd16.prod.outlook.com> |
Hi,
We are migrating to log4j2 from log4j1. We are using bridge API. I am finding issues with bridge API when I tried migrate.
Log4j.xml
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true"/>
<rollingPolicy class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
<param name="FileNamePattern" value="${app.home.dir}/logs/app.log.%i"/>
<param name="ActiveFileName" value="${app.home.dir}/logs/app.log"/>
<param name="MaxIndex" value="13" />
</rollingPolicy>
<triggeringPolicy class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="maxFileSize" value="3145728" />
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] [%X{logCorId}] %c - %m%n"/>
</layout>
</appender>
For this, bridge API is not recognizing the class, “org.apache.log4j.rolling.RollingFileAppender”
I changed the class to "org.apache.log4j.RollingFileAppender" to make it work.
New log4j.xml
<appender name=" FILE" class="org.apache.log4j.RollingFileAppender">
<param name="Append" value="true"/>
<param name="FileNamePattern" value="app.log.%i" />
<param name="ActiveFileName" value="logs/app.log" />
<param name="MaxBackupIndex" value="13" />
<param name="MaxFileSize" value="3072" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] [%X{logCorId}] %c - %m%n"/>
</layout>
</appender>
After the changes into log4j.xml as mentioned above logs started printing into log file. But the rolling over of file is causing issue. File name I needed is app.log, app.log.1, app.log.2 so on…
Issue1: But roll over file name is just having app<Date>.log while we want filename as app.log, app.log.1, app.log.2…
Issue2: org.apache.log4j.rolling.RollingFileAppender class is not supported by bridge API
Issue3: When added <param name="File" value="logs/app.log.%i" /> instead of <param name="ActiveFileName" value="logs/app.log" />
The rolling file name is created with app.log.1, app.log.2…
But the first file name is app.log.%i instead of app.log
How can we address these issues? I appreciate your time to look into these issues.
Regards,
Pavithra
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows