Log4j.xml throw file not found in j2ee application

cheapdruggi

New Member
I am trying to log using log4j in my j2ee application in the following way where i have defined a log4j.xml in the application.I am trying to access it using \[code\] DOMConfigurator.configure( "src/log4j.xml"); logger.warn( "Login Process has started a warning message" );\[/code\]but it keeps throwing the following error** edited error message\[code\]log4j:ERROR Could not parse file [src/log4j.xml]. java.io.FileNotFoundException: D:\src\log4j.xml (The system cannot find the path s pecified)at java.io.FileInputStream.open(Native Method)at java.io.FileInputStream.<init>(FileInputStream.java:120)at java.io.FileInputStream.<init>(FileInputStream.java:79)at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:749)at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:866)at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755)\[/code\]When i provided the absolute path everything is working .So whats the way to achieve this? I am using 1.2.16.jar version of log4jand i get following warning each time i build the app\[code\]log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.\[/code\]Edited:Application struture\[code\]Myapp src conf target\[/code\]and i have palced log4j.xml under folder srclog4j.xml file\[code\]<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"><appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="http://stackoverflow.com/questions/13760766/System.out" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="http://stackoverflow.com/questions/13760766/%-5p %c{1} - %m%n" /> </layout></appender> <appender name="Log" class="org.apache.log4j.FileAppender"> <param name="File" value="http://stackoverflow.com/questions/13760766/Web.log" /> <param name="Append" value="http://stackoverflow.com/questions/13760766/true" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="http://stackoverflow.com/questions/13760766/%d{DATE} %-5p %-15c{1}: %m%n" /> </layout></appender><logger name="com.web" additivity="false"> <level value="http://stackoverflow.com/questions/13760766/info" /> <appender-ref ref="Log" /></logger></log4j:configuration>\[/code\]Thanks
 
Back
Top