The World’s Largest Online Community for Developers

'; log4j2 - I want to migrate log4j to log4j 2. Need help in recreating the log4j 2.xml - LavOzs.Com

<log4j:configuration xmlns:log4j="">
    <appender name="logfile" class="org.apache.log4j.RollingFileAppender">
        <param name="threshold" value="TRACE" />
        <param name="File" value=x.log" />
        <param name="MaxFileSize" value="10000KB"/>
        <param name="MaxBackupIndex" value="19"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{MM/dd/yyyy HH:mm:ss:SSS} %-5p [%t] (%30.30c) %x - %m%n"/>

Can someone give me the log4j 2.xml of this. How this should be migrated to log4j2. how it looks the code once replaced by log4j .xml

You can use as shown below.

<?xml version="1.0" encoding="UTF-8"?>

    <Console name="STDOUT" target="SYSTEM_OUT">
        <param name="Target" value="System.out"/>
        <PatternLayout pattern="%d{MM/dd/yyyy HH:mm:ss:SSS} %-5p [%t] (%30.30c) %x - %m%n""/>

    <RollingFile name="rollingFile"
        <PatternLayout pattern="%d{MM/dd/yyyy HH:mm:ss:SSS} %-5p [%t] (%30.30c) %x - %m%n"" />
            <SizeBasedTriggeringPolicy size="10000KB" />
        <DefaultRolloverStrategy max="19"/>


    <Logger name="file" level="INFO">
        <AppenderRef ref="rollingFile" />

    <Root level="info">
        <AppenderRef ref="STDOUT"/>
        <AppenderRef ref="rollingFile" />
Log4J2 - assigning file appender filename at runtime
How to customize log4j2 RollingFileAppender?
How to configure StatisticsCsvLayout in log4j2
log4j2 threshold for consoleappender
Migrating from Log4j 1.x to Log4j2
How to create multiple log files in log4j2 using property file?
Access spring profile in log4j2 for spring boot application