0

I have a jar of an application which i don't have the sources,and when i executed with java -cp app.jar class conf i got this warning :

log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

I have read in this forum that i have to add log4j.properties in the classpath, since i don't have the sources i have tried this command :

java -cp app.jar:* class conf

but still the same warning are they any way to fix log4j problem without recompiling from the sources ?

azelix
  • 1,257
  • 4
  • 26
  • 50
  • possible douplicate: http://stackoverflow.com/search?q=appenders+could+be+found – Timothy Truckle Oct 16 '16 at 10:12
  • Possible duplicate of [No appenders could be found for logger(log4j)?](http://stackoverflow.com/questions/12532339/no-appenders-could-be-found-for-loggerlog4j) – Timothy Truckle Oct 16 '16 at 10:12
  • Like I said in my question I searched in stack overflow before creating this topic . I have added log4j'properties to my cp while executing the jar but it doesn't work – azelix Oct 16 '16 at 10:16

2 Answers2

1

add a log4j configuration file to the resources of your project

https://logging.apache.org/log4j/2.x/manual/configuration.html

java -cp app.jar:folder/containing/log4/config:* class conf

user found this solution:

$ java -Dlog4j.configuration=file:"./log4j.properties" -cp app-1.0.14.jar APP app.conf
Timothy Truckle
  • 15,071
  • 2
  • 27
  • 51
  • Like I have said in my question I don't have the sources of this project I only have a jar so I don't know how to add the log4j.properties to the jar – azelix Oct 16 '16 at 10:13
  • this does not matter, just put the configuration file in any classpath root folder – Timothy Truckle Oct 16 '16 at 10:15
  • it didnt work for me but it helped me find the answer , can you please add this to your answer so i can accept it : $ java -Dlog4j.configuration=file:"./log4j.properties" -cp app-1.0.14.jar APP app.conf – azelix Oct 16 '16 at 10:29
0

Have you tried to unzip the jar file?

It may contain the original log4j file you're looking for.

Also you can use a decompiler (like this one) to see what's happening in the code.

I hope this helps.