繁体   English   中英

Spring MVC的log4j 1.2配置问题

[英]log4j 1.2 configuration issue with Spring mvc

我被困住了。 我在使用Spring MVC设置log4j时遇到配置问题。 得到以下错误。

log4j:WARN No appenders could be found for logger (org.springframework.web.servlet.DispatcherServlet).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

这是我的控制器代码

     public class HelloWorldController {

private static Logger logger = Logger.getLogger(HelloWorldController.class);

int first_no=10;
int second_no=10;
int summation;
@RequestMapping("/helloworld")
   public String helloWord(ModelMap modelview){

    summation=first_no+second_no;

    System.out.println("Inside hello world");


    logger.info("Hello, World!");
      modelview.addAttribute("message", summation);

         return "helloworld";
    }
}

这是我的log4j.properties文件

    # Direct log messages to stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

   # Root logger option
   log4j.rootLogger=debug, file, stdout

我将文件保存在Eclipse的src / resources下。 谁能帮我这个忙吗? 我被困住了。

可能log4j.properties文件不在类路径中。在容器中部署时,将Eclipse中src文件夹中的log4j.properties和WEB-INF / classes下移动。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM