1

I'm trying to log into a html file using Log4j filappender. My properties file looks as follows

log = C:\Log
log4j.rootLogger = DEBUG, FILE

# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/logfile.html

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.HTMLLayout
log4j.appender.FILE.layout.Title=log
log4j.appender.FILE.layout.LocationInfo=true

But it didn't create the logfile at C:\Log so I thought i didn't work at all but i found that it creates the logfile.html and the folder as well within my .netbeans folder (C:Users\Peter.netbeans\7.1.1\config\GF3\domain1\Log). I'm using Netbeans 7.1.1. I haven't used Log4j before and to be honest I have no idea why it does this. Any ideas?

Thanks for your time

HRgiger
  • 2,750
  • 26
  • 37
Peter
  • 1,047
  • 2
  • 18
  • 32

2 Answers2

3

This is the line that is defining where to save the logfile: log4j.appender.FILE.File=${log}/logfile.html

If you change that to log4j.appender.FILE.File=C:/log/logfile.html Then it might work.

AFAIK, the first line in your config log = C:\Log have no effect whatsoever. You can't use variables like that in your config file.

Simon Forsberg
  • 13,086
  • 10
  • 64
  • 108
1

The single backslash in your first line could be the problem:

log = C:\Log

Either use C:\Log or C:/Log.

I would write the path directly into

log4j.appender.FILE.File

without using the log = C:\Log

AlexWien
  • 28,470
  • 6
  • 53
  • 83