Reputation: 329
Hi I am using logger file in my application as mentioned below and it is logging contents in console and log file perfectly. But still while launching the application it is showing warning "WARN No appenders could be found for logger". The only difference in my case is the xml name is logger.xml.
Why i am getting this warning even the xml is correct and logging all stuff in console as well in file. If i make the copy of same logger.xml file and name it log4j.xml, application did not show any warning.
Is it really require to name logger.xml as log4j.xml or log4j.properties?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="Standard" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="../classes/test.log"/>
<param name="Append" value="true"/>
<param name="maxFileSize" value="2097152"/> <!-- maximum filesize in bytes -->
<param name="maxBackupIndex" value="1"/> <!-- number of backup files -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%-6p] %d{yyyy/MM/dd HH:mm:ss} [%t] %c.%M(): %m%n"/>
</layout>
</appender>
<appender name="Console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%-6p] %c.%M : %m%n"/>
</layout>
</appender>
<root>
<!-- possible values of priority: "DEBUG", "INFO", "WARN", "ERROR" -->
<priority value="ERROR" />
<appender-ref ref="Standard"/>
<appender-ref ref="Console"/>
</root>
</log4j:configuration>
Upvotes: 0
Views: 938
Reputation: 1186
Log4j has a dedicated way in how it searches for the logfile. The detailed process is documented in the documentation.
To cut things short, if you want to use a different file, you need to set it in the log4j.configurationFile
system property.
Upvotes: 1