Suppose I have the following code:
private static final Logger log = LoggerFactory.getLogger( DummyTest.class );
@Test
public void test() {
log.info("dummy log");
}
When I run the test method test()
in Intellij, I didn't get any log in the console output. However, if I run the test via mvn test
from commandline, I will get the log. BTW, I use testng.
So, how can I make Intellij to show the log?
on the Test Runner toolbar. If you haven't run any tests yet, and the tool window with the Test Runner toolbar is not available, press Ctrl+Shift+A and type Import Tests from File . In the dialog that opens, select the . xml file with test results and click Open.
Notifications tool window has replaced Event Log that existed in earlier versions of the IDE. All notifications and events that occur in IntelliJ IDEA are gathered in the Notifications tool window. You can open the tool window by clicking the corresponding tool window bar on the right side of the editor.
Set a breakpoint before you start the application in the debug mode. The various step actions are: Step Over (F8) lets you execute a line of code and move on to the next line. As you step through the code, you'll see the value of the variables next to the code in the editor window.
I had the same problem - no log output at all in console.
Taking @wemu's advice, I added the following file to the src/test/resources/
directory of my project, which gave me the debug ouput from both the test code and the classes under test.
Note: I'm using log4j2. The file needed will vary according to your logging framework.
log4j.xml:
<?xml version='1.0' encoding='UTF-8'?>
<configuration monitorInterval="30">
<appenders>
<Console name='Console' target='SYSTEM_OUT'>
<PatternLayout pattern='%d{HH:mm:ss.SSS} %p [%t] %c{1.}.%M %m%n' />
</Console>
</appenders>
<loggers>
<root level='trace'>
<appender-ref ref='Console' />
</root>
</loggers>
</configuration>
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