log4j:ERROR setFile(null,false) call failed

24,746

Solution 1

In addition to Chandra's answer, I experienced the same exception in Eclipse on Windows 7:

C:/myfile.log                     // access denied...

But it worked OK when I created a folder with permissions to my userid:

 C:/myLogs/myfile.log             // it wasn't necessary to create the file

I also noticed that the path must be specified with forward slashes.

Solution 2

Use forward slash ('/') instead of back slash ('\') where ever you are defining this path ${logging.folder}. Thats what error i see up there:

you are using back slash here:

java.io.FileNotFoundException: \debug.log (Access is denied)

so your path should be something like: logging.folder = D:/logs/

Share:
24,746

Related videos on Youtube

user3128668
Author by

user3128668

Updated on February 14, 2020

Comments

  • user3128668
    user3128668 about 4 years

    Iam facing some strange error as below

    log4j:ERROR setFile(null,false) call failed.
    java.io.FileNotFoundException: \debug.log (Access is denied)
    

    src/main/dev/environment/dev/config.properties

    logging.folder=D:/logs
    

    log4j.xml

    <appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
          <param name="append" value="false"/>
          <param name="file" value="${logging.folder}/debug.log"/>
          <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
          </layout>
       </appender>
    

    maven.xml (not complete)

    <filters>
                <filter>src/main/environment/dev/config.properties</filter>
            </filters>
    

    when iam directly using <param name="file" value="D:/logs/debug.log"/> , its working fine, BUT when am using <param name="file" value="${logging.folder}/debug.log"/> iam getting above exception..

    Iam pretty sure values from property file able to read, since one of my java file able to read values from this property file only.. then why can't this log4j.xml file able to read?

    please suggest me what went wrong?

    • chrylis -cautiouslyoptimistic-
      chrylis -cautiouslyoptimistic- over 10 years
      It really looks like the config.properties isn't getting read before the XML attribute is getting interpreted. I also note that your paths don't match, and you haven't specified the environment in which you're getting the error (is it a configuration where dev isn't enabled?).
    • user3128668
      user3128668 over 10 years
      @chrylis profile 'dev' is by-default enabled.. so can you tell me whats the solution for my issue pls? and when iam directly using <param name="file" value="D:/logs/debug.log"/> , its working fine for me..
    • JavaTec
      JavaTec almost 8 years
      user3128668 - did you find answer to the above?