當前位置: 首頁>>代碼示例>>Java>>正文


Java RollingFileAppender.setName方法代碼示例

本文整理匯總了Java中ch.qos.logback.core.rolling.RollingFileAppender.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java RollingFileAppender.setName方法的具體用法?Java RollingFileAppender.setName怎麽用?Java RollingFileAppender.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.core.rolling.RollingFileAppender的用法示例。


在下文中一共展示了RollingFileAppender.setName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
protected Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    layout.start();
    appender.setEncoder(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:25,代碼來源:DynamicLogbackLogger.java

示例2: buildDailyMaxRollingAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
protected Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    layout.start();
    appender.setEncoder(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:26,代碼來源:DynamicLogbackLogger.java

示例3: buildAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
protected Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    rolling.setContext(loggerContext);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayout layout = new PatternLayout();
    layout.setPattern(pattern);
    layout.setContext(loggerContext);
    layout.start();
    appender.setLayout(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:24,代碼來源:DynamicLogback918Logger.java

示例4: buildDailyMaxRollingAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
protected Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setContext(loggerContext);
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setContext(loggerContext);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    rolling.start();
    appender.setRollingPolicy(rolling);

    PatternLayout layout = new PatternLayout();
    layout.setContext(loggerContext);
    layout.setPattern(pattern);
    layout.start();
    appender.setLayout(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:25,代碼來源:DynamicLogback918Logger.java

示例5: buildAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private Appender buildAppender(String name, String fileName, String pattern) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setParent(appender);
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd}");
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    appender.setEncoder(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:20,代碼來源:DynamicLogbackLogger.java

示例6: buildDailyMaxRollingAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private Appender buildDailyMaxRollingAppender(String name, String fileName, String pattern, int maxBackupIndex) {
    RollingFileAppender appender = new RollingFileAppender();
    appender.setName(name);
    appender.setAppend(true);
    appender.setFile(new File(getLogPath(), fileName).getAbsolutePath());

    TimeBasedRollingPolicy rolling = new TimeBasedRollingPolicy();
    rolling.setFileNamePattern(new File(getLogPath(), fileName).getAbsolutePath() + ".%d{yyyy-MM-dd-HH}");
    rolling.setMaxHistory(maxBackupIndex);
    rolling.setParent(appender);
    appender.setRollingPolicy(rolling);

    PatternLayoutEncoder layout = new PatternLayoutEncoder();
    layout.setPattern(pattern);
    layout.setCharset(Charset.forName(getEncoding()));
    appender.setEncoder(layout);
    // 啟動
    appender.start();
    return appender;
}
 
開發者ID:beebeandwer,項目名稱:TDDL,代碼行數:21,代碼來源:DynamicLogbackLogger.java

示例7: addFileAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
public static void addFileAppender(String name, String logPattern, String filePath, int maxHistory) {
	RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
       fileAppender.setFile(filePath);
       fileAppender.setEncoder(getPatternLayoutEncoder(logPattern));
       fileAppender.setContext(loggerContext);
       fileAppender.setName(name);
       fileAppender.setAppend(true);
       
       // time based rolling policy
       TimeBasedRollingPolicy<ILoggingEvent> logFilePolicy = new TimeBasedRollingPolicy<>();
    logFilePolicy.setContext(loggerContext);
    logFilePolicy.setParent(fileAppender);
    logFilePolicy.setFileNamePattern(getDateBasedFileName(filePath));
    logFilePolicy.setMaxHistory(50);
    logFilePolicy.start();
    
    fileAppender.setRollingPolicy(logFilePolicy);
       fileAppender.start();

       registeredAppenders.put(name, fileAppender);
}
 
開發者ID:sangupta,項目名稱:jerry-core,代碼行數:22,代碼來源:ApplicationLogger.java

示例8: getAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private FileAppender<ILoggingEvent> getAppender(String pluginId) {
    File pluginLogFileLocation = pluginLogFile(pluginId);

    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
    rollingFileAppender.setEncoder(LogHelper.encoder());
    rollingFileAppender.setContext(LogHelper.LOGGER_CONTEXT);
    rollingFileAppender.setFile(pluginLogFileLocation.getPath());
    rollingFileAppender.setName(rollingFileAppenderName(pluginId));

    LogHelper.rollingPolicyForAppender(
            rollingFileAppender,
            "5 MB",
            "20 MB",
            7
    );

    rollingFileAppender.start();
    return rollingFileAppender;
}
 
開發者ID:gocd,項目名稱:gocd,代碼行數:20,代碼來源:DefaultPluginLoggingService.java

示例9: rollingAppender

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private RollingFileAppender<ILoggingEvent> rollingAppender(String file) throws IOException {
    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<>();
    rollingFileAppender.setEncoder(LogHelper.encoder("%date{ISO8601} - %msg%n"));
    rollingFileAppender.setContext(LogHelper.LOGGER_CONTEXT);
    rollingFileAppender.setFile(getEffectiveLogDirectory(file));
    rollingFileAppender.setName(UUID.randomUUID().toString());

    LogHelper.rollingPolicyForAppender(
            rollingFileAppender,
            "5 MB",
            "20 MB",
            4
    );
    rollingFileAppender.start();
    return rollingFileAppender;
}
 
開發者ID:gocd,項目名稱:gocd,代碼行數:17,代碼來源:AgentOutputAppender.java

示例10: configureFileLogging

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private static OutputStreamAppender<ILoggingEvent> configureFileLogging(File logFile, LoggerContext loggerContext) {
    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
    rollingFileAppender.setFile(logFile.getAbsolutePath());
    rollingFileAppender.setName("com.documents4j.logger.client.file");
    rollingFileAppender.setContext(loggerContext);
    FixedWindowRollingPolicy fixedWindowRollingPolicy = new FixedWindowRollingPolicy();
    fixedWindowRollingPolicy.setFileNamePattern(logFile.getAbsolutePath() + ".%i.gz");
    fixedWindowRollingPolicy.setMaxIndex(LogDescription.MAXIMUM_LOG_HISTORY_INDEX);
    fixedWindowRollingPolicy.setContext(loggerContext);
    fixedWindowRollingPolicy.setParent(rollingFileAppender);
    SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
    sizeBasedTriggeringPolicy.setMaxFileSize(LogDescription.MAXIMUM_LOG_FILE_SIZE);
    sizeBasedTriggeringPolicy.setContext(loggerContext);
    rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
    rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);
    sizeBasedTriggeringPolicy.start();
    fixedWindowRollingPolicy.start();
    System.out.println("Logging: The log is written to " + logFile);
    return rollingFileAppender;
}
 
開發者ID:documents4j,項目名稱:documents4j,代碼行數:21,代碼來源:StandaloneClient.java

示例11: configureFileLogging

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
private static OutputStreamAppender<ILoggingEvent> configureFileLogging(File logFile, LoggerContext loggerContext) {
    RollingFileAppender<ILoggingEvent> rollingFileAppender = new RollingFileAppender<ILoggingEvent>();
    rollingFileAppender.setFile(logFile.getAbsolutePath());
    rollingFileAppender.setName("com.documents4j.logger.server.file");
    rollingFileAppender.setContext(loggerContext);
    FixedWindowRollingPolicy fixedWindowRollingPolicy = new FixedWindowRollingPolicy();
    fixedWindowRollingPolicy.setFileNamePattern(logFile.getAbsolutePath() + ".%i.gz");
    fixedWindowRollingPolicy.setMaxIndex(LogDescription.MAXIMUM_LOG_HISTORY_INDEX);
    fixedWindowRollingPolicy.setContext(loggerContext);
    fixedWindowRollingPolicy.setParent(rollingFileAppender);
    SizeBasedTriggeringPolicy<ILoggingEvent> sizeBasedTriggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
    sizeBasedTriggeringPolicy.setMaxFileSize(LogDescription.MAXIMUM_LOG_FILE_SIZE);
    sizeBasedTriggeringPolicy.setContext(loggerContext);
    rollingFileAppender.setRollingPolicy(fixedWindowRollingPolicy);
    rollingFileAppender.setTriggeringPolicy(sizeBasedTriggeringPolicy);
    sizeBasedTriggeringPolicy.start();
    fixedWindowRollingPolicy.start();
    System.out.println("Logging: The log is written to " + logFile);
    return rollingFileAppender;
}
 
開發者ID:documents4j,項目名稱:documents4j,代碼行數:21,代碼來源:StandaloneServer.java

示例12: doInitializer

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
/**
 * Initializer logback
 * 
 * @param file
 * @param level
 * @param maxHistory
 */
private void doInitializer(String file, String level, int maxHistory) {
	LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
	Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
	rootLogger.detachAndStopAllAppenders();

	// appender
	RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
	fileAppender.setContext(loggerContext);
	fileAppender.setName("application");
	fileAppender.setFile(file);
	fileAppender.setAppend(true);

	// policy
	TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<ILoggingEvent>();
	policy.setContext(loggerContext);
	policy.setMaxHistory(maxHistory);
	policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}");
	policy.setParent(fileAppender);
	policy.start();
	fileAppender.setRollingPolicy(policy);

	// encoder
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	encoder.setContext(loggerContext);
	encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
	encoder.start();
	fileAppender.setEncoder(encoder);
	
	fileAppender.start();

	rootLogger.addAppender(fileAppender);
	rootLogger.setLevel(Level.toLevel(level));
	rootLogger.setAdditive(false);
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:42,代碼來源:LogbackContainer.java

示例13: doInitializer

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
/**
 * Initializer logback
 *
 * @param file       log file
 * @param level      log level
 * @param maxHistory max history
 */
private void doInitializer(String file, String level, int maxHistory) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.detachAndStopAllAppenders();

    // appender
    RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<>();
    fileAppender.setContext(loggerContext);
    fileAppender.setName("application");
    fileAppender.setFile(file);
    fileAppender.setAppend(true);

    // policy
    TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<>();
    policy.setContext(loggerContext);
    policy.setMaxHistory(maxHistory);
    policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}");
    policy.setParent(fileAppender);
    policy.start();
    fileAppender.setRollingPolicy(policy);

    // encoder
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
    encoder.start();
    fileAppender.setEncoder(encoder);

    fileAppender.start();

    rootLogger.addAppender(fileAppender);
    rootLogger.setLevel(Level.toLevel(level));
    rootLogger.setAdditive(false);
}
 
開發者ID:linux-china,項目名稱:dubbo3,代碼行數:42,代碼來源:LogbackContainer.java

示例14: createFlusher

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
public static Flusher createFlusher(String name, String dir, String file) {
        Preconditions.checkArgument(new File(dir).exists(), String.format("dir[%s] not exist", dir));

//        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        LoggerContext context = new LoggerContext();
        Logger logger = context.getLogger(name);
        logger.setAdditive(false);

        RollingFileAppender rollingFileAppender = new RollingFileAppender();
        rollingFileAppender.setContext(context);
        rollingFileAppender.setName(name + "_appender");

        rollingFileAppender.setFile(dir + File.separator + file + ".dat");
        rollingFileAppender.setAppend(true);

        TimeBasedRollingPolicy rollingPolicy = new TimeBasedRollingPolicy();
        rollingPolicy.setFileNamePattern(dir + File.separator + file + ".%d{yyyy-MM-dd_HH}.dat");
        rollingPolicy.setParent(rollingFileAppender);
        rollingPolicy.setContext(context);
        rollingPolicy.start();

        PatternLayoutEncoder encoder = new PatternLayoutEncoder();
        encoder.setContext(context);
        encoder.setPattern("%msg%n");
        encoder.start();

        rollingFileAppender.setRollingPolicy(rollingPolicy);
        rollingFileAppender.setEncoder(encoder);
        rollingFileAppender.start();


        logger.addAppender(rollingFileAppender);

        return new Flusher(logger);
    }
 
開發者ID:alain898,項目名稱:distributed-search-cache,代碼行數:36,代碼來源:PersistUtils.java

示例15: doInitializer

import ch.qos.logback.core.rolling.RollingFileAppender; //導入方法依賴的package包/類
/**
 * Initializer logback
 *
 * @param file
 * @param level
 * @param maxHistory
 */
private void doInitializer(String file, String level, int maxHistory) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.detachAndStopAllAppenders();

    // appender
    RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
    fileAppender.setContext(loggerContext);
    fileAppender.setName("application");
    fileAppender.setFile(file);
    fileAppender.setAppend(true);

    // policy
    TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<ILoggingEvent>();
    policy.setContext(loggerContext);
    policy.setMaxHistory(maxHistory);
    policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}");
    policy.setParent(fileAppender);
    policy.start();
    fileAppender.setRollingPolicy(policy);

    // encoder
    PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    encoder.setContext(loggerContext);
    encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
    encoder.start();
    fileAppender.setEncoder(encoder);

    fileAppender.start();

    rootLogger.addAppender(fileAppender);
    rootLogger.setLevel(Level.toLevel(level));
    rootLogger.setAdditive(false);
}
 
開發者ID:hufeng,項目名稱:dubbo2.js,代碼行數:42,代碼來源:LogbackContainer.java


注:本文中的ch.qos.logback.core.rolling.RollingFileAppender.setName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。