Log4J out to console and file produces warnings/errors log4j:WARN File option not set for appender

eclipse, java, log4j

Solution

This will sound stupid - you have a typo. You have `log4j.appedner.logfile.File` instead of `log4j.appender.logfile.File` (note the 'n' and 'd' are switched). This is why it's complaining that you haven't set the File.

Problem

I'd like to integrate Log4J logging into my Java application, writing information out to a log file as well as displaying the info at the console. Unfortunately, I've had some trouble getting this off the ground. I'm working with Eclipse Juno on Win 7. My log4j.properties file: ``` #configure logfile log4j.appender.logfile = org.apache.log4j.RollingFileAppender log4j.appedner.logfile.File = MyAppLog.log log4j.appender.logfile.Append = true log4j.appender.logfile.layout = org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n #configure stdout log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n log4j.rootLogger = debug, logfile, stdout ``` I belive the above follows the pattern of some other accepted answers on this topic. I've specifed the location of this log4j.properties file wtih a VM argument: ``` -Dlog4j.configuration=file:///${workspace_loc}\path\to\file\log4j.properties ``` I instantiate the logger in my java class: ``` static Logger logger = Logger.getLogger(MyApp.class.getName()); ``` log a string: ``` logger.info("barfoo"); ``` This configuration results in the following warnings/errors on launch: ``` log4j:WARN File option not set for appender [logfile]. log4j:WARN Are you using FileAppender instead of ConsoleAppender? log4j:ERROR No output stream or file set for the appender named [logfile] ``` It does not produce the log file. The console logging seems to be working just fine, however.

Original source