Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Log4j Error

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have written a Xml file

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

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/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"/>
</layout>
</appender>

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

</log4j:configuration>

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[]){
PropertyConfigurator.configure("D:\\Tomcat-5.5.7\\webapps\\PankajPractise\\filelog4jconfig.xml");

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
 
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try arranging your code so you try to create the Logger after you call PropertyConfigurator.configure.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!