This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Log4j Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j Error" Watch "Log4j Error" New topic

Log4j Error

pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
i have written a Xml file

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

<log4j:configuration xmlns:log4j="">

<appender name="appender" class="org.apache.log4j.FileAppender">
<param name="File" value="Indentify-Log.txt"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %p - %m%n"/>

<priority value ="debug"/>
<appender-ref ref="appender"/>


and java file

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class externalplaintest {

static Logger logger = Logger.getLogger(externalplaintest.class);
public static void main(String arg[]){

logger.debug("This is Debug");
logger.debug("This not a Debug");



i am getting the following error. Can any one solve my problem

log4j:WARN No appenders could be found for logger (externalplaintest).
log4j:WARN Please initialize the log4j system properly.

warm regards

Pankaj Patil
Paul Clapham

Joined: Oct 14, 2005
Posts: 19118

Try arranging your code so you try to create the Logger after you call PropertyConfigurator.configure.
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
For xml configuration use DOMConfigurator instead of PropertyConfigurator.

You can use -Dlog4j.debug to see what's going wrong with your configuration:

See the Short introduction to log4j for info about how to do get the debug flag set with tomcat if that's an issue.
It is sorta covered in the JavaRanch Style Guide.
subject: Log4j Error