Reputation: 173
I am having great trouble getting log4j to work with my little maven project. Running the program in Eclipse yields no errors, and the logging works perfectly. However, when I package the project into a jar, I get the following warning:
log4j:WARN No appenders could be found for logger (org.openrdf.sail.memory.MemoryStore).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
The log4j.properties file is packaged into my jar and it resides in src/main/resources for the project. I read this post and the configuration part of the log4j website, but can't figure it out. I have uploaded my POM here. I am thankful for any hint that may help me with my problem.
Upvotes: 2
Views: 2898
Reputation: 2776
You seems to assemble your jar with it's dependencies. This may cause problems if those jars also contain log4j.properties, and were picked up while over-riding yours. So, it can't find a logger for the class org.openrdf.sail.memory.MemoryStore
.
It's to use only one logger file which contain the logging info for your jar, and all the dependencies. It's just a matter of copy and paste. It gives the ability to control the logging level for dependency classes as well.
Upvotes: 0
Reputation: 17933
As warning message says, it can't find appender for logger org.openrdf.sail.memory.MemoryStore
. So, ensure you really have log4j.properties
file in src/main/resources
and then ensure it's packaged into jar
as you suppose. Maybe for some reason, I really can't see, it's not packaged. You know, shit sometimes happen... If have such file in a jar
, ensure at the end than you configured appender that handle org.openrdf.sail.memory.MemoryStore
logger.
Probably the simplest way of checking if this log4j configuration works is to set default console appender for log4j.rootLogger
. Do it and write what's going on there.
Upvotes: 1
Reputation: 1406
Add <resource>
tag under the <build></build>
tag. By doing this we say takes resources from the specified path if it is not taken default build.
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
Upvotes: 1