title: Why wasn't log message written my log file when running Junit tests?
body: <p>I have a class Store which contains statements like "log.info(...)". I can see the log messages with the log file created when running the program. However, when I run JUnit tests, the log file won't be created, but I still want to see log messages. The logger is:</p>
  
  <pre><code>import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  </code></pre>
  
  <p>And my log4j properties:</p>
  
  <pre><code>log4j.rootLogger=DEBUG, STDOUT, file
  
  log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
  log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
  log4j.appender.STDOUT.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
  
  log4j.appender.file=org.apache.log4j.RollingFileAppender
  log4j.appender.file.File=mylogs.log
  log4j.appender.file.layout=org.apache.log4j.PatternLayout
  log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n
  </code></pre>
  
  <p>The questions is, how to also create the log file and log messages when running my Junit tests?</p>
  
  <p>Edit:</p>
  
  <p>Part of the test log property:</p>
  
  <pre><code>log4j.rootLogger=ERROR, Console
  log4j.logger.play=DEBUG
  log4j.appender.Console=org.apache.log4j.ConsoleAppender
  log4j.appender.Console.layout=org.apache.log4j.PatternLayout
  log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %-5p ~ %m%n
  
  log4j.appender.file=org.apache.log4j.RollingFileAppender
  log4j.appender.file.File=testlog.log
  log4j.appender.file.layout=org.apache.log4j.PatternLayout
  log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n
  </code></pre>