I am trying to configure log4j for my core
java application but getting error "log4j:WARN No appenders could be found for logger" and "Please initialize the log4j system properly".
Location of log4j.config: Inside the jar.
The jar of my application: myApp.jar has the log4j.properties file.
If i do jar -tf myApp.jar it shows the .class files and log4j.jar too.
If the log4j.properties file is in the jar and and i run Main.java class the log4j.properties file should be in the class path but it gives error message as above.
log4j.properties file:
#define the root logger with appender file
log = /home/user/
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.file.File=/home/user/loging.log
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n
Main.java class is in the jar and so is the log4j.properties.
I expected that when I run Main.java class it should automatically find log4j.properties since it is also inside the same jar.
Inside the Main.java, I have the below code:
(both the properties file as well as Main.java are in com folder)
despite that the error message which I recieve is:
log4j:WARN No appenders could be found for logger (com.Main).
log4j:WARN No appenders could be found for logger (com.Main).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN Please initialize the log4j system properly.
Please advice.
Thanks