Log4j2.xml not writing logs into the logfile.log


I have a log4j2.xml and when I complete executing selenium TC, the logfile.log gets created with 0 bytes. Tried changing the content on log4j2.xml but not successful. Does anyone has any idea what is wrong?

Find below the content in log4j2.xml

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
<RollingFile name="RollingFile" filename="logfile.log"
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" />
<SizeBasedTriggeringPolicy size="100 MB" />
<DefaultRolloverStrategy max="20" />
<Root level="info">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />

If I use below content  then it gives 'main ERROR Unknown object "root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].' error

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

    xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

    <appender name="fileAppender"

        <param name="Threshold" value="INFO" />

        <param name="File" value="logfile.log" />

        <layout class="org.apache.log4j.PatternLayout">

            <param name="ConversionPattern" value="%d %-5p [%c{1}] %m %n" />




        <level value="INFO" />

        <appender-ref ref="fileAppender" />



Please sign in to leave a comment.