After adding log4j to my application I get the following output every time I execute my application:
log4j:WARN No appenders could be found for logger (slideselec
To enable -Dlog4j.debug
, I go to System, Advanced system settings, Environment variables and set system variable _JAVA_OPTIONS
to -Dlog4j.debug
.
The fix for me was to put "log4j.properties" into the "src" folder.
Find a log4j.properties or log4j.xml online that has a root appender, and put it on your classpath.
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
log4j.rootLogger=debug, stdout
will log to the console. I prefer logging to a file so you can investigate afterwards.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.maxFileSize=100KB
log4j.appender.file.maxBackupIndex=5
log4j.appender.file.File=test.log
log4j.appender.file.threshold=debug
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug,file
although for verbose logging applications 100KB usually needs to be increased to 1MB or 10MB, especially for debug.
Personally I set up multiple loggers, and set the root logger to warn or error level instead of debug.
You can set the location of your log4j.properties from inside your java app by using:
org.apache.log4j.PropertyConfigurator.configure(file/location/log4j.properties)
More information is available here: https://logging.apache.org/log4j/1.2/manual.html
I just did this and the issue was fixed.
Followed the below blog
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206875685-How-to-fix-log4j-WARN-console-messages-when-running-an-Application-inside-IntelliJ-Idea
But here he says like below
To fix that just enter the following log4j.resources file into main/resources folder of your project
instead of creating log4j.resources, create log4j.properties. Right Click on Resource in IntelliJ -> New -> Resource Bundle - Just name it as log4j
Try to set debug attribut in log4j:configuration node to true.
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
It prints out information as the configuration file is read and used to configure the log4j environment. You may be got more details to resolve your problem.