Update - this problem was my own work.
At one point, this particular test class had a test to ensure that something was registered. In setup, I previously uninstalled all applications and added my own appender to accept time test statements. This test has long gone, but this nugget has remained in the configuration: Logger.getRootLogger().removeAllAppenders();
.
Sorry for the false alarm. :)
In IDEA, I have the following test:
@Test public void shouldLog() { URL resource = Thread.currentThread().getContextClassLoader() .getResource("log4j.properties"); System.out.println("resource = " + resource); final Logger logger = Logger.getLogger(getClass()); logger.info("Hello world"); }
It outputs in this way:
"C:\Program Files\Java\jdk1.5.0_18\bin\java" -classpath "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 11.1\lib\idea_rt.jar" -ea -Dfile.encoding=UTF-8 com.intellij.rt.execution.CommandLineWrapper C:\DOCUME~1\JMAWSO~1.NT3\LOCALS~1\Temp\classpath2294205410661538428.tmp @vm_params C:\DOCUME~1\JMAWSO~1.NT3\LOCALS~1\Temp\vm_params5645362020129462784.tmp com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 au.com.gmm.repo.RepoThreadCleanupServiceTest,shouldLog resource = file:/C:/user/jem/projects/GMM/out/test/cashflow/log4j.properties log4j:WARN No appenders could be found for logger (au.com.gmm.repo.RepoThreadCleanupServiceTest). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html
This is a known issue that many beginners have seen over and over again. Today I feel a little stupid. [/ P>
http://logging.apache.org/log4j/1.2/faq.html#noconfig says log4j uses Thread.getContextClassLoader().getResource() to locate the default configuration files
. However, my test checks Thread.currentThread().getContextClassLoader().getResource("log4j.properties")
and finds the properties file without problems.
File contents:
log4j.rootLogger=DEBUG, CONSOLE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss.SSS} %c - %m%n
source share