title: Java Application: Getting Log4j To Work Within Eclipse Environment
body: <p>I've done my best to setup Eclipse and my Java application to use a <code>log4j.properties</code> file.  However, it does not seem to be using the properties file and I'm not sure why.</p>
  
  <p>Libraries: slf4j-api-1.6.1, slf4j-jdk14-1.6.1</p>
  
  <p>Within the application the logging works fine.  I am able to print info, warnings, and errors into the Eclipse console.</p>
  
  <p>What I would like to be able to do is change the log level to debug and print all logging messages to both the console and a log file.</p>
  
  <p>I have created a <code>log4j.properties</code> file that looks like this:</p>
  
  <pre><code>log4j.rootLogger=DEBUG,console,file
  log4j.rootCategory=DEBUG, R, O
  
  # Stdout
  log4j.appender.O=org.apache.log4j.ConsoleAppender
  
  # File
  log4j.appender.R=org.apache.log4j.RollingFileAppender
  log4j.appender.R.File=log4j.log
  
  # Control the maximum log file size
  log4j.appender.R.MaxFileSize=100KB
  
  # Archive log files (one backup file here)
  log4j.appender.R.MaxBackupIndex=5
  log4j.appender.file.File=checkLog.log
  log4j.appender.file.threshold=DEBUG
  
  log4j.appender.R.layout=org.apache.log4j.PatternLayout
  log4j.appender.O.layout=org.apache.log4j.PatternLayout
  
  log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
  log4j.appender.O.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x - %C.%M(%F:%L) - %m%n
  </code></pre>
  
  <p>My directory structure looks like this:</p>
  
  <pre><code>My Project
  --src/
  ----MYProject/
  ------*.java
  --bin/
  ----MYProject/
  ------*.class
  --log4j/
  ----log4j.properties
  </code></pre>
  
  <p>In Eclipse I this this:</p>
  
  <p><em>Run Configurations -> Classpath (tab) -></em>, right clicked on <em>User Entries</em> -> Added "log4j" as a new folder, and saved.</p>
  
  <p>Then in my code I call the logger like this (sample code to demonstrate my approach so it may have syntax errors):</p>
  
  <pre><code>package MYProject;
  import org.slf4j.LoggerFactory;
  
  public class MyClass{
  
    final org.slf4j.Logger test_logger = LoggerFactory.getLogger(MyClass.class);
  
    public MyClass(){}
  
    public someMethod(){
      test_logger.debug("Some Debug");
      test_logger.info("Some Info");
      test_logger.warn("Some Warning");
      test_logger.error("An Error");
    }
  
  }
  </code></pre>
  
  <p>I then call <code>someMethod</code> and it prints <code>INFO</code>, <code>WARN</code>, <code>ERROR</code> to the Eclipse console.  It won't print <code>DEBUG</code> and won't print to a file.</p>
  
  <p>I'd appreciate any suggestions on what I may be doing wrong.</p>