当前位置: 首页>>代码示例>>Java>>正文


Java DailyRollingFileAppender.setName方法代码示例

本文整理汇总了Java中org.apache.log4j.DailyRollingFileAppender.setName方法的典型用法代码示例。如果您正苦于以下问题:Java DailyRollingFileAppender.setName方法的具体用法?Java DailyRollingFileAppender.setName怎么用?Java DailyRollingFileAppender.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.DailyRollingFileAppender的用法示例。


在下文中一共展示了DailyRollingFileAppender.setName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SecureLog

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
/**
 * Constructs a log which writes log entries to the given log file.
 *
 * @param title     Identifies the log entries
 * @param logfile   Location of the log file
 */
public SecureLog(String title, String logfile) throws IOException {
    defaultLog = new FileOutputStream(logfile);
    logAppender = new DailyRollingFileAppender(defaultLayout, logfile, rotationInterval);
    logAppender.setName(defaultLogName);

    // Configure the logging options
    //logRoot = new SecureCategory(title);
    logRoot = (SecureCategory)SecureCategory.getLogger(title);

    logRoot.addAppender(logAppender);
    setLogLevel(DEBUG);
    logEntry(this, DEBUG, 
        "Constructing " + title + " log.  Initial log level is DEBUG.  " +
        "Output will be sent to: " + logfile);
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:22,代码来源:SecureLog.java

示例2: setupLogger

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
@Override
public void setupLogger() {
	String file =checkFile();
	DailyRollingFileAppender fa = new DailyRollingFileAppender();
	fa.setName("FileLogger");
	fa.setFile(file);
	fa.setLayout(new PatternLayout(pattern));
	setLevel(fa);
	fa.setAppend(true);
	fa.activateOptions();
	Logger.getRootLogger().addAppender(fa);
}
 
开发者ID:DTStack,项目名称:jlogstash,代码行数:13,代码来源:Log4jComponent.java

示例3: buildAppender

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
private Appender buildAppender(String name, String fileName, String pattern) {
    DailyRollingFileAppender appender = new DailyRollingFileAppender();
    appender.setName(name);
    appender.setAppend(true);
    appender.setEncoding(getEncoding());
    appender.setLayout(new PatternLayout(pattern));
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());
    appender.activateOptions();// 很重要,否则原有日志内容会被清空
    return appender;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:11,代码来源:DynamicLog4jLogger.java

示例4: createAppender

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
public static Appender createAppender(Path logdir, String name, Layout layout) {
  final DailyRollingFileAppender dst = new DailyRollingFileAppender();
  dst.setName(name);
  dst.setLayout(layout);
  dst.setEncoding(UTF_8.name());
  dst.setFile(resolve(logdir).resolve(name).toString());
  dst.setImmediateFlush(true);
  dst.setAppend(true);
  dst.setErrorHandler(new DieErrorHandler());
  dst.activateOptions();
  dst.setErrorHandler(new OnlyOnceErrorHandler());
  return dst;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:SystemLog.java

示例5: addLogfile

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
/**
 * Start logging to an additional log file location.
 *
 * @param   logfile     New logfile location
 */
public void addLogfile(String logfile) throws IOException {
    Appender existing = logRoot.getAppender(logfile);
    if (existing == null) {
        logEntry(this, INFO, "Adding new log file: " + logfile);
        logAppender = new DailyRollingFileAppender(defaultLayout, logfile, rotationInterval);
        logAppender.setName(logfile);
        logRoot.addAppender(logAppender);
        if (!logFiles.contains(logfile)) {
            logFiles.add(logfile);
        }
    } else {
        logEntry(this, DEBUG, "Log file already active: " + logfile);
    }
}
 
开发者ID:ModelN,项目名称:build-management,代码行数:20,代码来源:SecureLog.java

示例6: resolveCurrentTenantLogger

import org.apache.log4j.DailyRollingFileAppender; //导入方法依赖的package包/类
@Override
public Logger resolveCurrentTenantLogger() {
	
	if (currentLoggers.containsKey(multiTenantContextResolver.resolveCurrentTenantIdentifier())) {
		return currentLoggers.get(multiTenantContextResolver.resolveCurrentTenantIdentifier());
	}
	
	try {
		
		Class<?> appenderClass = Class.forName(appender);
		Appender appenderObject = (Appender)appenderClass.newInstance();
		
		if (appenderObject instanceof DailyRollingFileAppender) {
			
			DailyRollingFileAppender drfa = new DailyRollingFileAppender();
			
			if (!rootPath.endsWith("/")) rootPath = rootPath + "/";
               String logFileName = rootPath + multiTenantContextResolver.resolveCurrentTenantIdentifier();
               File logFile = new File(logFileName);
               if (!logFile.exists()) logFile.mkdir();
			drfa.setFile(logFileName + "/audit.log");
			
			drfa.setDatePattern(datePattern);
			PatternLayout layoutObject = null;
			try {
			    layoutObject = (PatternLayout) Class.forName(layout).newInstance();
			} catch (ClassCastException cce) {
				throw new Exception(layout + " log4j layout not supported!");
			}
			layoutObject.setConversionPattern(layoutConversionPattern);
			drfa.setLayout(layoutObject);

			drfa.setAppend(true);
			drfa.setName(prefix + "." + multiTenantContextResolver.resolveCurrentTenantIdentifier());
			drfa.setThreshold(Level.toLevel(threshold));
			
			drfa.activateOptions();
			
			org.apache.log4j.Logger myLogger = org.apache.log4j.LogManager.getLogger(prefix + "." + multiTenantContextResolver.resolveCurrentTenantIdentifier());
			myLogger.addAppender(drfa);

			Logger logger = new Log4jLoggerAdapter(myLogger);
			currentLoggers.put(multiTenantContextResolver.resolveCurrentTenantIdentifier(), logger);
			return logger;
			
		} else {
			throw new Exception(appenderClass.getName() + " log4j appender not supported!");
		}
		
	} catch (Exception e) {
		log.warn("Multitenant logger not initialized for " + prefix + "." + multiTenantContextResolver.resolveCurrentTenantIdentifier(), e);
	}
	
	return null;
	
}
 
开发者ID:keensoft,项目名称:icearchiva,代码行数:57,代码来源:Log4JMultiTenancyLoggerResolver.java


注:本文中的org.apache.log4j.DailyRollingFileAppender.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。