mindreader
mindreader

Reputation: 1812

How to print logs on console in Intellij?

Can't get logs to show up on console while running unit tests. Instead, I see this message every time I run a unit test -

log4j:WARN No appenders could be found for logger. 
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

log4j.properties contains this -

log4j.rootLogger=info, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

I'm pretty sure that this needs to be configured in run configurations but just can't get it to work. Would really appreciate any help on this. Thanks!

Upvotes: 1

Views: 19112

Answers (1)

mindreader
mindreader

Reputation: 1812

Finally got it to work! Added this to VM options -

-Dlog4j.configuration=file:{path-to-properties-file}/log4j.properties

as explained here by 30thh.

I had it added in my default unit test configuration, but it wasn't being picked up by current configuration.

Upvotes: 2

Related Questions