Log4j works for one class and doesn't work for the other class
I am developing a Spring MVC 3.0.4 webapp and Logger factroy doesn'开发者_运维知识库t work for the Controller classes other than HomeController.java. I initilize the Logger factory like:
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
private static final Logger logger = LoggerFactory.getLogger(RequestDataController.class);
and
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
is added for both classes
What configuration is missing?
It seems SLF4J is missconfigured. You use it for you own logging and that's a right choice! But Spring has JCL logging framework hardcoded. It's an abstarction layer that is typically configured with Log4J implementation. Please, visit this link where some JCL-to-SLF4J drop-in replacements described. If you want to leave both Log4J and SLF4j in your project than add proper logging preferences into log4j.properties or log4j.xml for core spring packages.
精彩评论