Reputation: 77
I have a package called Resources in which I have placed my log4j.properties file. When I run my code, I get the following error:
log4j:WARN No appenders could be found for logger.
log4j:WARN Please initialize the log4j system properly.
How should I update the classpath to include Resource folder ?
Solution tried:
I added the log4j.properties file directly under 'source' and it worked.
Here is the contents of properties file:
#Application Logs
log4j.logger.devpinoyLogger=DEBUG, dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.maxFileSize=5000KB
log4j.appender.dest1.maxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n
log4j.appender.dest1.File=C:\\Users\\kagarwal\\Desktop\\Application.log
log4j.appender.dest1.Append=false
Upvotes: 0
Views: 6254
Reputation: 2786
Right click on the folder, select Build Path
then Use as a Source Folder
.
Just remember that when you will deploy you will need to create a directory for resources and add it to class path.
You should also consider to use maven for your java project, it may seem overkill initially but it will pay off in the long run.
Upvotes: 3