Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud

I am planing to move web application to cloudfoundry along with mysql service. But I am getting below error.

Its working fine with local environment. log file get generated also.

<strong>Below is error log:</strong>

Jan 5, 2013 7:35:59 AM org.cloudfoundry.reconfiguration.AbstractServiceConfigurer configure INFO: No beans of type org.springframework.amqp.rabbit.connection.ConnectionFactory found in application context Jan 5, 2013 7:35:59 AM org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart Jan 5, 2013 7:35:59 AM org.apache.catalina.core.StandardContext start SEVERE: Context [] startup failed due to previous errors log4j:WARN Continuable parsing error 109 and column 23 log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appender*,plugin*,(category|logger)*,root?,(categoryFactory|loggerFactory)?)". log4j:ERROR setFile(null,true) call failed. java.io.FileNotFoundException: /logs/abc-web.log (No such file or directory) at java.io.FileOutputStream.openAppend(Native Method) at java.io.FileOutputStream.<init>(FileOutputStream.java:177) at java.io.FileOutputStream.<init>(FileOutputStream.java:102) at org.apache.log4j.FileAppender.setFile(FileAppender.java:290) at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:194) at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:164) at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257) at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:285) at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:171) at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:184) at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:502) at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:471) at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:921) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:790) at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696) at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821) at org.springframework.util.Log4jConfigurer.initLogging(Log4jConfigurer.java:69) at org.springframework.web.util.Log4jWebConfigurer.initLogging(Log4jWebConfigurer.java:151) at org.springframework.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:45) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository. Stopping Tomcat because the context stopped.


<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender"> <param name="MaxFileSize" value="25MB" /> <param name="MaxBackupIndex" value="10" /> <param name="File" value="/logs/abc-web.log" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p: %m (%c)%n" /> </layout> </appender>


Log4j will create directories while the directory and it's parent directory not exists.

Log4j throws FileNotFoundException while creating directory or file failed without file priviledge.

Check the file priviledge with your app user.

public synchronized void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize) throws IOException { LogLog.debug("setFile called: "+fileName+", "+append); // It does not make sense to have immediate flush and bufferedIO. if(bufferedIO) { setImmediateFlush(false); } reset(); FileOutputStream ostream = null; try { // // attempt to create file // ostream = new FileOutputStream(fileName, append); } catch(FileNotFoundException ex) { // // if parent directory does not exist then // attempt to create it and try to create file // see bug 9150 // String parentName = new File(fileName).getParent(); if (parentName != null) { File parentDir = new File(parentName); if(!parentDir.exists() && parentDir.mkdirs()) { ostream = new FileOutputStream(fileName, append); } else { throw ex; } } else { throw ex; } }


I had this same issue of the FileNotFound exception.

My solution was to remove the appended "/" from the value as so:

<param name="File" value="logs/abc-web.log" />


  • Show progress percentage of h:inputFile upload
  • Creating a new MS Access file in Java using Jackcess
  • Table-driven test for file creation
  • Populate Multiple Forms Symfony2
  • how to get file name from the server request?
  • How to create table in ms word doc with rowspan and colspan using apache POI?
  • Strange behavior of javascript RegExp: same regular expressions produce different result [duplicate]
  • No internet connectivity inside docker container running inside kubernetes with weave as networking
  • Get row for each user where the count of a value in a column is maximum
  • No error while instantiating abstract class, even though abstract method is not implemented
  • Where does the file get saved using “File file = new file(filename)” in Android
  • Google datalab : how to import pickle
  • css font-size and line-height not matching the baseline
  • Using extern @class in order to add a category?
  • Replace and retrieve placeholder value
  • Graceful pod termination
  • insert a picture into database(sqlite) with java code. what should i do?
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • Setting the run time properties on SpringApplicationBuilder()
  • Web.config system.webserver errors
  • copying resource to sdcard gives a damaged file in android
  • Checking free space on FTP server
  • Change Inet root folder for iis 7
  • Cross-Platform Protobuf Serialization
  • Updated Ionic CLI but shows previous version (Windows)
  • How to format a variable of double type
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • coudnt use logback because of log4j
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • LevelDB C iterator
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • JaxB to read class hierarchy
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • How can i traverse a binary tree from right to left in java?
  • How can I use `wmic` in a Windows PE script?
  • Why do underscore prefixed variables exist?