Re: Issues with bridge API while migrating to log4j 2

Apache <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <[email protected]>
Please try using the latest code in the release-2.x branch - 2.17.2-SNAPSHOT. There have been over 50 fixes to the bridge applied.

Ralph

> On Feb 21, 2022, at 3:16 AM, Kudethur, Pavithra (Enterprise) <[email protected]> wrote:
> 
> 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
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.