dcsimg
log4j directory creation
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sairam_Krishnamurthy
Posted On:   Tuesday, March 25, 2008 06:43 AM

Hi, I tried to use log4j for my application. I am new to log4j and at first I created a new application to get familiar with log4j. The following is the appender's properties in log4j.property file. log4j.appender.A2=org.apache.log4j.FileAppender log4j.appender.A2.File=c:/demo1/demo2/app.log log4j.appender.A2=org.apache.log4j.RollingFileAppender # Append to the end of the file or overwrites the file at start. log4j.appender.A2.Append=true log4j.appender.A2.layout=org.apache.log4j.PatternLayout log4j.appender.A2.layout.ConversionPattern=[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n A2 is the logger appender i use. I dint have demo1/demo2    More>>

Hi,


I tried to use log4j for my application. I am new to log4j and at first I created a new application to get familiar with log4j. The following is the appender's properties in log4j.property file.



			log4j.appender.A2=org.apache.log4j.FileAppender
			

log4j.appender.A2.File=c:/demo1/demo2/app.log

log4j.appender.A2=org.apache.log4j.RollingFileAppender

# Append to the end of the file or overwrites the file at start.

log4j.appender.A2.Append=true

log4j.appender.A2.layout=org.apache.log4j.PatternLayout

log4j.appender.A2.layout.ConversionPattern=[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n


A2 is the logger appender i use. I dint have demo1/demo2 folder in C:. When i used this log4j configuration in my sample application it was a success with demo1/demo2 folder created by log4j.



But when i tried to use the same configuration in my application it gives the following error.



			log4j:ERROR setFile(null,true) call failed.
			

java.io.FileNotFoundException: testapp.log (The system cannot find the path specified)

at java.io.FileOutputStream.openAppend(Native Method)

at java.io.FileOutputStream. (Unknown Source)

at java.io.FileOutputStream. (Unknown Source)

at org.apache.log4j.FileAppender.setFile(FileAppender.java:282)

at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:165)

at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:161)

at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:256)

at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:132)

at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:96)

at org.apache.log4j.PropertyConfigurator



Also when i changed the filename = "app.log" with no folder name, the log file is creating in my source folder. So the problem was with the creation of directory.



Can somebody help me in this?



Thanks in advance.

   <<Less
About | Sitemap | Contact