title: How to manage log4j.properties in coding jUnit for web servlet
body: <p>I'm developing web servlet and having confusion with log4j.properities,
  and I defined to call initialize logger in constructor.</p>
  
  <pre><code>public static Logger logger = Logger.getLogger(MyProject.class.getName());
  public MyProject() {
      super();
      // TODO Auto-generated constructor stub
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      URL url = loader.getResource("log4j.properties");
      PropertyConfigurator.configure(url);
  }
  </code></pre>
  
  <p>In general, logging file about web servlet refers to tomcat's log directory.</p>
  
  <pre><code>log4j.rootLogger=debug, R
  log4j.appender.R=org.apache.log4j.RollingFileAppender
  log4j.appender.R.File=${catalina.base}/logs/myproject.log
  log4j.appender.R.MaxFileSize=100KB
  log4j.appender.R.MaxBackupIndex=1
  log4j.appender.R.layout=org.apache.log4j.PatternLayout
  log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
  </code></pre>
  
  <p>But, while coding jUnit for webservlet,
  logging file refers to improper address because ${catalina.base} is blank text.
  Error log is here.</p>
  
  <pre><code>[junit] log4j:ERROR setFile(null,true) call failed.
  [junit] java.io.FileNotFoundException: /logs/myproject.log (No such file or directory)
  </code></pre>
  
  <p>So, please teach me wise management about log file.
  I hope stopping output log file while testing by jUnit.</p>