2015-05-22 49 views
0

我有一個log4j的問題,在控制檯中什麼都不寫,也不會生成日誌文件。我在eclipse控制檯上沒有錯誤,沒有例外,也沒有消息,它只是無所事事。Log4j什麼都不寫

log4j.properties(在SRC /主/資源)

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

# Redirect log messages to console 
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{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 

# Redirect log messages to a log file, support file rolling. 
log4j.appender.file=org.apache.log4j.RollingFileAppender 
log4j.appender.file.File=C:/log4j-application.log 
log4j.appender.file.MaxFileSize=5MB 
log4j.appender.file.MaxBackupIndex=10 
log4j.appender.file.layout=org.apache.log4j.PatternLayout 
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 

我的樣品控制器:

@Controller 
public class HomeController { 

    @Autowired 
    ParametroImpl param; 

    final static Logger logger = Logger.getLogger(HomeController.class); 

    @RequestMapping(value="/") 
    public ModelAndView test(HttpServletResponse response) throws IOException{ 
     logger.info("PACOPEPE"); 
     return new ModelAndView("home"); 

    } 
} 

什麼建議嗎?

+0

當你有控制器,你在哪裏部署這個webapp?服務器在eclipse或獨立服務器? – Setu

回答

1

更改爲

log4j.rootCategory=DEBUG, stdout, file 
0

你可以嘗試把你的log4j.properties在SRC

或更改記錄儀

final static Logger logger = Logger.getLogger(HomeController.class); 

final static Logger logger = LogManager.getLogger(HomeController.class.getName());