很奇怪"没有找到记录器的追加者"与netbean maven(Windows)

时间:2017-11-11 02:48:56

标签: java maven netbeans

我有一个snippset 我在Linux中使用的次数非常多,完全没有问题。但在Windows上失败了。

log4j: Using URL [file:/C:/Users/vbb/Documents/NetBeansProjects/MailNotification/./log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL file:/C:/Users/vbb/Documents/NetBeansProjects/MailNotification/./log4j.properties
log4j: Could not find root logger information. Is this OK?
log4j: Finished configuring.
log4j:WARN No appenders could be found for logger (com.mycompany.mailnotification.Main).
log4j:WARN Please initialize the log4j system properly.

这样的代码:

 System.setProperty("log4j.configuration", new File(".", File.separatorChar + "log4j.properties").toURL().toString());
        final  Logger logger = Logger.getLogger(Main.class);
        logger.debug("Program start!");

这是从src\main\resourcessrc\test\resources到处放置的属性文件...在linux中,我只是将它放在项目文件夹中。

# 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=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

0 个答案:

没有答案