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


Java RollingFileAppender.setName方法代码示例

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


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

示例1: initLogger

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
private RollingFileAppender initLogger(String loggerName, String filePrefix) {
  String fileName = Paths.get(rootPath, filePrefix + "." + loggerName + ".dat").toString();
  RollingFileAppender fileAppender = new RollingFileAppender();
  fileAppender.setName(loggerName);
  fileAppender.setFile(fileName);
  fileAppender.setLayout(new PatternLayout("%m%n"));
  fileAppender.setAppend(true);
  fileAppender.setMaxFileSize(maxFileSize);
  fileAppender.setMaxBackupIndex(maxFileCount);
  fileAppender.activateOptions();
  return fileAppender;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:Log4JMetricsFileWriter.java

示例2: CreateRollingFileAppender

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
/**
 * Create File appender, This appender is responsible to write stream of data when invoked, in our case, this appender is handeled my the Bufferappender
 *
 * @param cacheName Name of the file appender
 * @param fileName Filename to which is to write logs
 * @return returns the created appender
 */
private Appender CreateRollingFileAppender(String fileName)
{
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName("RollingFileAppender" + _loggerName);
    appender.setFile(fileName);
    //doesnt matter since all files are created with a new name
    appender.setAppend(false);

    appender.setMaxBackupIndex(Integer.MAX_VALUE);
    appender.setMaxFileSize("5MB");

    String str = "%-27d{ISO8601}" /*+ "\t%-45.42appdomain" + "\t%-45.42l"*/ + "\t%-42t" + "\t%-9p" + "\t%m" + "%n";

    appender.setThreshold(Level.ALL);

    return appender;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:25,代码来源:CacheLogger.java

示例3: setup

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
public static void setup(Level level, String logLocation) {
    if (logLocation != null) {
        RollingFileAppender fa = new RollingFileAppender();
        fa.setName("FileLogger");
        fa.setFile(logLocation);
        fa.setMaxFileSize("5MB");
        fa.setMaxBackupIndex(1);
        fa.setLayout(new PatternLayout("%d | %-5p| %c{1} | %m%n"));
        fa.setThreshold(level);
        fa.setAppend(true);
        fa.activateOptions();
        Logger.getRootLogger().addAppender(fa);
        LOGGER.info("File Handler set");
    } else {
        System.out.println("Log location is not set, not logging to file");
    }
}
 
开发者ID:DataDog,项目名称:jmxfetch,代码行数:18,代码来源:CustomLogger.java

示例4: initAppenders

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
private static void initAppenders() throws IOException {
    systemLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "system.log");
    accessLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "access.log");
    auditLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "audit.log");
    reverseProxyLogAppender = new RollingFileAppender(getLayout(),
            logFilePath + File.separatorChar + "reverseproxy.log");

    // setting the max backup index and file size
    systemLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    systemLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    systemLogAppender.setName(systemLogAppenderName);

    accessLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    accessLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    accessLogAppender.setName(accessLogAppenderName);

    auditLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    auditLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    auditLogAppender.setName(auditLogAppenderName);

    reverseProxyLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    reverseProxyLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    reverseProxyLogAppender.setName(reverseProxyLogAppenderName);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:28,代码来源:LoggerFactory.java

示例5: beforeClass

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws IOException
{
  String logFileDir = new File("target" + File.separator + "logDir").getAbsolutePath();
  logFileName = logFileDir + File.separator + "appTest.log";
  RollingFileAppender rfa = new RollingFileAppender(new PatternLayout("%d{ISO8601} [%t] %-5p %c{2} %M - %m%n"),
      logFileName);
  rfa.setName(APPENDER_NAME);
  logger.addAppender(rfa);
}
 
开发者ID:apache,项目名称:apex-core,代码行数:11,代码来源:LogFileInformationTest.java

示例6: configureLog4J

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
/**
 * Configures the Log4J properties
 * 
 * @param logFilePath
 *            The log file path
 */
private void configureLog4J(String logFilePath) {

	// This is the root logger provided by log4j
	Logger rootLogger = Logger.getRootLogger();
	rootLogger.setLevel(Level.DEBUG);

	// Define log pattern layout
	PatternLayout layout = new PatternLayout("[%-5p] %d %c - %m%n");

	// Add console appender to root logger
	if (rootLogger.getAppender(LOG_CONSOLE_APPENDER_NAME) == null) {
		ConsoleAppender consoleAppender = new ConsoleAppender(layout);
		consoleAppender.setName(LOG_CONSOLE_APPENDER_NAME);
		rootLogger.addAppender(consoleAppender);
	}

	// Add file appender with layout and output log file name
	try {
		if (rootLogger.getAppender(LOG_FILE_APPENDER_NAME) == null) {
			RollingFileAppender fileAppender = new RollingFileAppender(
					layout, logFilePath);
			fileAppender.setAppend(false);
			fileAppender.setImmediateFlush(true);
			fileAppender.setName(LOG_FILE_APPENDER_NAME);
			fileAppender.setMaxFileSize("5MB");
			fileAppender.setMaxBackupIndex(10);
			rootLogger.addAppender(fileAppender);
		}
	} catch (IOException e) {
		System.out.println("Failed to add appender !!");
	}
}
 
开发者ID:aguelle,项目名称:MIDI-Automator,代码行数:39,代码来源:Resources.java

示例7: installFileAppender

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
private void installFileAppender(String logFilename) {
    RollingFileAppender file = new RollingFileAppender();
    file.setName("FileAppender");
    file.setThreshold(logLevel);
    file.setFile(new File(logFilename).getAbsolutePath());
    file.setMaxFileSize(MAX_FILE_SIZE);
    file.setMaxBackupIndex(MAX_BACKUPS);
    file.setLayout(new PatternLayout(PATTERN));
    file.setAppend(true);
    file.activateOptions();

    Logger.getRootLogger().addAppender(file);
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:14,代码来源:LoggingConfigurator.java

示例8: init

import org.apache.log4j.RollingFileAppender; //导入方法依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    // Force the locale in order to not depend on the execution environment
    Locale.setDefault(new Locale(Constants.DEFAULT_LOCALE_ID));

    // Injects the webapp root
    String webappRoot = filterConfig.getServletContext().getRealPath("/");
    EnvironmentUtil.setWebappRoot(webappRoot);
    
    // Initialize the app directory
    File baseDataDirectory = null;
    try {
        baseDataDirectory = DirectoryUtil.getBaseDataDirectory();
    } catch (Exception e) {
        log.error("Error initializing base data directory", e);
    }
    if (log.isInfoEnabled()) {
        log.info(MessageFormat.format("Using base data directory: {0}", baseDataDirectory.toString()));
    }
    
    // Initialize file logger
    RollingFileAppender fileAppender = new RollingFileAppender();
    fileAppender.setName("FILE");
    fileAppender.setFile(DirectoryUtil.getLogDirectory() + File.separator + "books.log");
    fileAppender.setLayout(new PatternLayout("%d{DATE} %p %l %m %n"));
    fileAppender.setThreshold(Level.INFO);
    fileAppender.setAppend(true);
    fileAppender.setMaxFileSize("5MB");
    fileAppender.setMaxBackupIndex(5);
    fileAppender.activateOptions();
    org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender);
    
    // Initialize the application context
    TransactionUtil.handle(new Runnable() {
        @Override
        public void run() {
            AppContext.getInstance();
        }
    });
}
 
开发者ID:sismics,项目名称:books,代码行数:41,代码来源:RequestContextFilter.java


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