Error Could Not Read Configuration File From Url
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and propertyconfigurator.configure log4j.properties classpath policies of this site About Us Learn more about Stack Overflow the
Log4j.properties (the System Cannot Find The File Specified)
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users
Log4cxx Could Not Read Configuration File
Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes
Propertyconfigurator.configure Does Not Work
a minute: Sign up log4j Could not read configuration file up vote 3 down vote favorite I am adding logging to a java web project I am working on. I have run into an error that I am unable to figure out. The error I am getting from tomcat is: log4j:ERROR Could not read configuration file [log4j.properties]. java.io.FileNotFoundException: log4j.properties (No such log4j properties file file or directory) I have this simple method in my class: @RemotingInclude public UserAccount save(UserAccount dataObject) { PropertyConfigurator.configure("log4j.properties"); logger.debug(dataObject.toString()); return dao.save(dataObject); } When I look in my webapps//WEB-INF/class folder I do see my log4j.properties file. When I deploy to my tomcat server and restart tomcat, I do see my admin.log file created, but nothing is written to it. Even after hitting the method above. Any help with this is greatly appreciated. This is the current contents of my log4j.properties file: log4j.appender.AdminFileAppender=org.apache.log4j.FileAppender log4j.appender.AdminFileAppender.File=admin.log log4j.appender.AdminFileAppender.layout=org.apache.log4j.PatternLayout log4j.appender.AdminFileAppender.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n. log4j.appender.ReportFileAppender=org.apache.log4j.FileAppender log4j.appender.ReportFileAppender.File=report.log log4j.appender.ReportFileAppender.layout=org.apache.log4j.PatternLayout log4j.appender.ReportFileAppender.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n log4j.logger.com.rottmanj.services=WARN,AdminFileAppender java log4j share|improve this question edited Jun 29 '11 at 23:12 asked Jun 29 '11 at 23:06 rottmanj 3311621 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted That approach of bootstraping the Log4j is wrong. This is usually the way that is implemented: import org.apache.log4j.Logger; public class MyService { public UserAccount save(UserAccount dataObject) { logger.debug(dataObject.toString()); return dao.save(dataObject); } private static Logger logger = Logger.getLogger(MyService.class); } This way Log4j will automatically lookup for
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and log4j:error setfile(null,true) call failed. policies of this site About Us Learn more about Stack Overflow the log4j:warn no appenders could be found for logger company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users please initialize the log4j system properly. Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes http://stackoverflow.com/questions/6528287/log4j-could-not-read-configuration-file a minute: Sign up How to configure log4j with a properties file up vote 17 down vote favorite 9 How do I get log4j to pick up a properties file. I'm writing a Java desktop app which I want to use log4j. In my main method if have this: PropertyConfigurator.configure("log4j.properties"); The log4j.properties file sits in the same directory when I open the http://stackoverflow.com/questions/2288876/how-to-configure-log4j-with-a-properties-file Jar. Yet I get this error: log4j:ERROR Could not read configuration file [log4j.properties]. java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified) What am I doing wrong? java properties log4j share|improve this question asked Feb 18 '10 at 13:29 Dan 14.3k37120181 The log4j.properties file must be in the root folder of your main application (since you're writing a desktop application). –Buhake Sindi Feb 18 '10 at 13:34 add a comment| 8 Answers 8 active oldest votes up vote 39 down vote I believe that the configure method expects an absolute path. Anyhow, you may also try to load a Properties object first: Properties props = new Properties(); props.load(new FileInputStream("log4j.properties")); PropertyConfigurator.configure(props); If the properties file is in the jar, then you could do something like this: Properties props = new Properties(); props.load(getClass().getResourceAsStream("/log4j.properties")); PropertyConfigurator.configure(props); The above assumes that the log4j.properties is in the root folder of the jar file. share|improve this answer edited Feb 19 '10 at 5:50 answered Feb 18 '10 at 13:35 kgiannakakis 76.1k16124166 An absolute path in the jar or the filesystem? –Dan Feb 18 '10
and http://forum.spring.io/forum/spring-projects/container/57661-log4j-error-could-not-read-configuration-file to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor. Announcement Announcement Module Collapse No announcement yet. log4j:ERROR Could not read configuration file Page Title Module Move Remove Collapse X could not Conversation Detail Module Collapse Posts Latest Activity Search Forums Page of 1 Filter Time All Time Today Last Week Last Month Show All Discussions only Photos only Videos only Links only Polls only Filtered by: Clear All could not read new posts andrew007 Senior Member Join Date: Aug 2008 Posts: 105 #1 log4j:ERROR Could not read configuration file Jan 8th, 2009, 11:19 AM Hello, I have a problem with Spring 2.5.5 and log4j 1.2.14. Basically, sometimes I have the following exception which disappear when I restart Tomcat: Code: log4j:ERROR Ignoring configuration file [jar:file:/C:/Documents%20and%20Settings...]. log4j:ERROR Could not read configuration file from URL [jar:file:/C:/Documents%20and%20Settings...]. java.io.FileNotFoundException: JAR entry log4j.properties not found in ... at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122) at sun.net.www.protocol.jar.JarURLConnection.getInputStream(JarURLConnection.java:132) at java.net.URL.openStream(URL.java:1009) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:433) at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:336) at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:73) at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:152) at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:511) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1231) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.