0

I have a main class to test some of the functions, I am getting error:

WARN No appenders could be found for logger (Jena).

I searched online, and I found this answer to solve the problem

Configure Eclipse for Log4j

One of the answers says that I should create a file called log4j.properties in the bin folder. However, when I do that, I get this problem:

Error: Could not find or load main class com.blablabla.Main

If I remove that file from the bin folder, i go back to the first problem.

Community
  • 1
  • 1
Ania David
  • 1,168
  • 1
  • 15
  • 36

1 Answers1

1

do likewise,

put your log4j.properties file into resource directory(if you are using Eclipse IDE then otherwise put it where it load to your Runtime Environment)

and into your log4j.properties file set appender properly, For Example : log4j.properties will look like after completely configure,

log4j.rootLogger=DEBUG, FILE

log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.file=${path}/logFile2.log
log4j.appender.FILE.Append=true
log4j.appender.FILE.Encoding=UTF-8
log4j.appender.FILE.MaxFileSize=10MB
log4j.appender.FILE.MaxBackupIndex=10
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n
Vishal Gajera
  • 4,137
  • 5
  • 28
  • 55
  • I put my resources in src/main/resources, should I put the log4j.properties there as well? should I copy what you've wrote to that file as well please? – Ania David Mar 28 '16 at 09:46
  • please, provide correct location where you want to create your log file. ignore my provided path , '=${path}/logFile2.log' or just type logFile2.log. – Vishal Gajera Mar 28 '16 at 09:54