0

I get below error and the log files is not created. I know log4j.properties is not being picked correctly

log4j:WARN No appenders could be found for logger
  1. log4j jar is in lib and classpath
  2. log4j.properties is in src folder and gets loaded to classes folder on build

I tried many ways to fix this error like adding services folder with log4j implementation class to fix WAS logging conflict also tried sfl4j

Has anyone found a way to fix log4j issue with WAS7 or later ?

Axel Isouard
  • 1,498
  • 1
  • 24
  • 38
Kris
  • 719
  • 1
  • 11
  • 19
  • You can try to externalize your properties file and load it via VM argument : `-Dlog4j.configuration=` – yodamad Sep 29 '12 at 09:20
  • Is your code using log4j directly or over commons logging? Or still trying over sl4j like you pointed out in the question? – bluefoot Jan 08 '13 at 18:14
  • I think this has already been answered [here][1] [1]: http://stackoverflow.com/questions/6608775/please-initialize-the-log4j-system-properly-while-running-web-service – JCalfucura Jan 22 '13 at 13:12

3 Answers3

1

You can troubleshoot Log4J itself by specifying the log4j.debug=true system variable. Then you'll know exactly what's going on with Log4J, internally.

Does your log4j.properties file contain any logger definitions? perhaps you can paste the file here?

Isaac
  • 16,458
  • 5
  • 57
  • 81
0

I had this same problem (WAS ignoring my META-INF/services/org.apache.commons.logging.LogFactory file).

The problem was solved when I downgraded commons-logging to 1.0.3, to match WAS version. Check this article for more info.

bluefoot
  • 10,220
  • 11
  • 43
  • 56
-1

Consider using the Java Logging framework instead, which is built into the standard Java Runtime Environment and requires no additional installations or configuration. The relevant classes are in the java.util.logging package and there is an overview of the process for using them here (it works in a very similar way to log4j).

Neil Weightman
  • 331
  • 2
  • 4
  • 1
    This is not answer to the question. Wheter use Log4J or not, this is whole different story. Changing logging framework may require lot of effort, since one need to refactor every class, where logging is used. And IMHO it is not that good idea to replace Log4J with java.util.logging.Logger. It may be good for smaller projects, but lacks flexibility. – Radium Jun 08 '15 at 12:29