带有Spring MVC 3.2.8应用程序的logj4

时间:2017-05-11 08:57:15

标签: java spring spring-mvc logging log4j

我使用logj4在Spring Web模型 - 视图 - 控制器(MVC)框架中有一个应用程序。这是我的log4j.properties

log4j.rootCategory=INFO, console, logfile

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601}] %5p [%t] %x (%C:%L) - %m%n

org.apache.log4j.rolling.TimeBasedRollingPolicy


log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=logs/noentenimnicinc.log
log4j.appender.logfile.MaxFileSize=1512KB
log4j.appender.logfile.Threshold=INFO
log4j.appender.logfile.Append=true
log4j.appender.logfile.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.logfile.RollingPolicy.FileNamePattern=ecat_admin.%d{yyyy-MM-dd-HH}.gz

# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=10
# Pattern to output: date priority [category] - message
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{ISO8601}] %5p [%t] %x (%C:%L) - %m%n

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Threshold=CONSOLE
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{ISO8601}] %5p [%t] %x (%C:%L) - %m%n

和我的控制员:

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;

@Controller
public class NoEnTenimNiCinc {

    private static final Logger LOGGER = Logger.getLogger   (NoEnTenimNiCinc.class);

    private void fer () {

        LOGGER.info("***************************************************************");
        LOGGER.info("   SUBMITTING THE APPLICATION ");
        LOGGER.info("***************************************************************");

        System.out.println  ("System.out***************************************************************");
        System.out.println  ("System.out    SUBMITTING THE APPLICATION ");
        System.out.println  ("System.out***************************************************************");
    }       
}

据我了解,我应该在eclipse控制台中看到所有消息,但我只看到System.out.println

生成的消息

0 个答案:

没有答案