private static void initLog4J() {
ConsoleAppender console = new ConsoleAppender();
console.setLayout(new EnhancedPatternLayout("%d %-5p [%t] %c.%M - %m%n %throwable{short}"));
console.setThreshold(Level.DEBUG);
console.activateOptions();
Logger.getRootLogger().addAppender(console);
}
java类org.apache.log4j.EnhancedPatternLayout的实例源码
Main.java 文件源码
项目:swingsane
阅读 21
收藏 0
点赞 0
评论 0
ExtrasRollingAppenderFactory.java 文件源码
项目:Aletheia
阅读 21
收藏 0
点赞 0
评论 0
public Set<? extends Appender> createNewAppender(final String appenderName,
final String logFolderFullPath,
final String shortFileName) {
final String fullFileName = FilenameUtils.concat(logFolderFullPath, shortFileName);
final String fileNamePattern = String.format("%s.%s", fullFileName, suffixPattern);
final RollingFileAppender rollingFileAppender = new RollingFileAppender();
rollingFileAppender.setName(appenderName);
rollingFileAppender.setImmediateFlush(immediateFlush);
Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown));
rollingFileAppender.setLayout(new EnhancedPatternLayout(layout));
final TimeBasedRollingPolicy timeBasedRollingPolicy = getTimeBasedRollingPolicy(fileNamePattern);
rollingFileAppender.setRollingPolicy(timeBasedRollingPolicy);
rollingFileAppender.activateOptions();
return Collections.singleton(rollingFileAppender);
}