0

I am trying to write a log4j logfile using Netbeans Java. I succeded writing the log file to C:\tmp\log.txt , but for some reason i have no premission to write it at the root of my project : log.txt.

This is my log4j.properties:

log4j.rootLogger = all, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=log.txt <- failes

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%5p](%F:%L) %m%n
log4j.appender.FILE.Append=false
omriman12
  • 1,644
  • 7
  • 25
  • 48

1 Answers1

0

Have you try this :

log4j.appender.FILE.File=./log.txt

. represents the current folder (usually the project root folder). Maybe the log file that you set are placed somewhere in root of your drive.


This reference may useful for you :

Where Are Your Log4j Log Files?

Community
  • 1
  • 1
Wayan Wiprayoga
  • 4,472
  • 4
  • 20
  • 30
  • @omriman12, Its good practice to specify complete path explicitly to avoid unnecessary frustration. – Alpesh Gediya May 09 '13 at 13:40
  • @omriman12 You can check the reference that I provided on my updated answer – Wayan Wiprayoga May 09 '13 at 13:55
  • this refference seems like what i need but still not working for me. forgot to mention that i am using a webservice – omriman12 May 09 '13 at 14:15
  • I don't get idea about the relationship between webservice and log the message. What you have done when you succed to write log on `C:\tmp\log.txt`? Are you use absolute path on the configuration? – Wayan Wiprayoga May 09 '13 at 14:21