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:
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.
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).
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.
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
Look in the log4j.properties
or log4j.xml
file for the log level. It's probably set to ERROR
instead of DEBUG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With