Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log4j output not displayed in Eclipse console

For some reason my Eclipse console no longer displays Log4j INFO and DEBUG statements when I run JUnit tests. In terms of code there hasn't been any change, so it must something to do with the Eclipse configuration.

All I do in my Unit test is the following and for some reason ONLY the ERROR statement is displayed in the Eclipse console. Why? Where shall I look for clues?

public class SampleTest {    private static final Logger LOGGER = Logger.getLogger(SampleTest.class);     @Before    public void init() throws Exception    {        // Log4J junit configuration.        BasicConfigurator.configure();         LOGGER.info("INFO TEST");        LOGGER.debug("DEBUG TEST");        LOGGER.error("ERROR TEST");    } } 

Details:

  • log4j-1.2.6.jar
  • junit-4.6.jar Eclipse
  • IDE for Java Developers, Version: Helios Release, Build id: 20100617-1415
like image 475
javaExpert Avatar asked Aug 17 '10 10:08

javaExpert


People also ask

How do I view logger information in Eclipse?

During development, you can browse and manipulate the platform log file using the Error Log view (Window > Show View > General > Error Log). You can also have the log file mirrored in the Java console by starting Eclipse with the -consoleLog command-line argument.

Why output is not showing in Eclipse?

If eclipse is not showing path, Please click on RUN-> Run configuration->click on environment tab->click on New-> add a path variable as mingw_path(if compiler is mingw in case of c++ ) and set value as C:\MinGw\bin (please check ur mingw bin path then only set).

How do I show console output in Eclipse?

From the menu bar, Window → Show View → Console. Alternately, use the keyboard shortcut: Mac: Option - Command - Q , then C , or. Windows: Alt - Shift - Q , then C.


2 Answers

Go to Run configurations in your eclipse then -VM arguments add this: -Dlog4j.configuration=log4j-config_folder/log4j.xml

replace log4j-config_folder with your folder structure where you have your log4j.xml file

like image 55
Huzi--- Javiator Avatar answered Sep 24 '22 23:09

Huzi--- Javiator


Look in the log4j.properties or log4j.xml file for the log level. It's probably set to ERROR instead of DEBUG

like image 43
Aaron Digulla Avatar answered Sep 23 '22 23:09

Aaron Digulla