I am absolutly new using log4j and I have the following problem.
I am trying to print the logging line into a file named log.out.
So I create the following log4j.properties configuration file:
# Define the root logger with appender file
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n
The problem is that, when I perform my application and when it incurs in a logging operation, something like this:
logger.debug("INTO main()");
I obtain the following exception into the console (the error message related to the log.out file is access denied (in italian Accesso negato):
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: \log.out (Accesso negato)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:289)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:163)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:2
56)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:132)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:96)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigura
tor.java:654)
and don't write nothing into my log.out file (that I have created manually). This log.out file is at the same level of the performed jar file that represent my application.
Why? What am I missing? How can I solve this issue?
Tnx