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


Java FileAppender.setPrudent方法代碼示例

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


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

示例1: buildFileAppender

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
public FileAppender<ILoggingEvent> buildFileAppender(LoggerContext context, String file) {
  FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
  fileAppender.setFile(file);
  fileAppender.setContext(context);
  fileAppender.setPrudent(true);

  PatternLayoutEncoder encoder = new PatternLayoutEncoder();
  encoder.setContext(context);
  encoder.setPattern(primaryConfiguration.getLoggingPattern().or(baseConfiguration.getLoggingPattern()).or(JavaUtils.LOGBACK_LOGGING_PATTERN));
  encoder.start();

  fileAppender.setEncoder(encoder);
  fileAppender.start();

  return fileAppender;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:17,代碼來源:SingularityRunnerBaseLogging.java

示例2: buildLoggerContext

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
static LoggerContext buildLoggerContext(String stamp, String filename,
    boolean safetyMode) {
  LoggerContext loggerContext = new LoggerContext();

  FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();

  PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
  patternLayout.setPattern(stamp + " %5p - %m%n");
  patternLayout.setContext(loggerContext);
  patternLayout.start();

  fa.setEncoder(patternLayout);
  fa.setFile(filename);
  fa.setAppend(true);
  fa.setPrudent(safetyMode);
  fa.setContext(loggerContext);
  fa.start();

  ch.qos.logback.classic.Logger root = loggerContext
      .getLogger(Logger.ROOT_LOGGER_NAME);
  root.addAppender(fa);

  return loggerContext;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:25,代碼來源:SafeModeFileAppender.java

示例3: buildLoggerContext

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
static LoggerContext buildLoggerContext(String filename, boolean safetyMode) {
  LoggerContext loggerContext = new LoggerContext();

  FileAppender<ILoggingEvent> fa = new FileAppender<ILoggingEvent>();

  PatternLayoutEncoder patternLayout = new PatternLayoutEncoder();
  patternLayout.setPattern("%5p %c - %m%n");
  patternLayout.setContext(loggerContext);
  patternLayout.start();

  fa.setEncoder(patternLayout);
  fa.setFile(filename);
  fa.setAppend(false);
  fa.setPrudent(safetyMode);
  fa.setContext(loggerContext);
  fa.start();

  ch.qos.logback.classic.Logger root = loggerContext
      .getLogger(Logger.ROOT_LOGGER_NAME);
  root.addAppender(fa);

  return loggerContext;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:24,代碼來源:FileAppenderPerf.java

示例4: testPrudentModeLogicalImplications

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
@Test
public void testPrudentModeLogicalImplications() {
  String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "fat-testPrudentModeLogicalImplications.txt";
  File file = new File(filename);
  FileAppender<Object> appender = new FileAppender<Object>();
  appender.setEncoder(new DummyEncoder<Object>());
  appender.setFile(filename);
  appender.setName("testPrudentModeLogicalImplications");
  appender.setContext(context);

  appender.setAppend(false);
  appender.setPrudent(true);
  appender.start();

  assertTrue(appender.isAppend());

  StatusManager sm = context.getStatusManager();
  //StatusPrinter.print(context);
  StatusChecker statusChecker = new StatusChecker(context);
  assertEquals(Status.WARN, statusChecker.getHighestLevel(0));
  List<Status> statusList = sm.getCopyOfStatusList();
  assertTrue("Expecting status list size to be 2 or larger, but was "
      + statusList.size(), statusList.size() >= 2);
  String msg1 = statusList.get(1).getMessage();

  assertTrue("Got message [" + msg1 + "]", msg1
      .startsWith("Setting \"Append\" property"));
  
  appender.doAppend(new Object());
  appender.stop();
  assertTrue(file.exists());
  assertTrue("failed to delete " + file.getAbsolutePath(), file.delete());
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:34,代碼來源:FileAppenderTest.java

示例5: buildFileAppender

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
private FileAppender<ILoggingEvent> buildFileAppender(AppenderType type, EncoderBase<ILoggingEvent> encoder, File file) {
    FileAppender<ILoggingEvent> appender = this.buildAppender(new FileAppender<>(), type, encoder, false);
    appender.setFile(file.getPath());
    appender.setPrudent(true);
    appender.start();

    return appender;
}
 
開發者ID:esacinc,項目名稱:sdcct,代碼行數:9,代碼來源:LoggingInitializerRunListener.java

示例6: buildFileAppender

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
public static FileAppender<ILoggingEvent> buildFileAppender(LoggingConfiguration.FileConfiguration file,
                                                            LoggerContext context,
                                                            String logFormat) {
    final LogFormatter formatter = new LogFormatter(context, file.getTimeZone());

    if (logFormat != null) {
        formatter.setPattern(logFormat);
    }
    formatter.start();

    final FileAppender<ILoggingEvent> appender =
            file.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
                    new FileAppender<ILoggingEvent>();

    appender.setAppend(true);
    appender.setContext(context);
    appender.setLayout(formatter);
    appender.setFile(file.getCurrentLogFilename());
    appender.setPrudent(false);

    addThresholdFilter(appender, file.getThreshold());

    if (file.isArchive()) {

        final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
                new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
        triggeringPolicy.setContext(context);

        final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
        rollingPolicy.setContext(context);
        rollingPolicy.setFileNamePattern(file.getArchivedLogFilenamePattern());
        rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggeringPolicy);
        triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
        rollingPolicy.setMaxHistory(file.getArchivedFileCount());

        ((RollingFileAppender<ILoggingEvent>) appender).setRollingPolicy(rollingPolicy);
        ((RollingFileAppender<ILoggingEvent>) appender).setTriggeringPolicy(triggeringPolicy);

        rollingPolicy.setParent(appender);
        rollingPolicy.start();
    }

    appender.stop();
    appender.start();

    return appender;
}
 
開發者ID:bither,項目名稱:bither-desktop-java,代碼行數:48,代碼來源:LogbackFactory.java

示例7: getFileAppender

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
private FileAppender<ILoggingEvent> getFileAppender(final LoggingSettings.LogFile settings,
                                                           final LoggerContext context) {
    final PatternLayout formatter = getPatternLayout(context);
    formatter.setPattern(settings.getLogFormat());
    formatter.start();

    final FileAppender<ILoggingEvent> appender =
        settings.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
                               new FileAppender<ILoggingEvent>();

    appender.setAppend(true);
    appender.setContext(context);
    appender.setLayout(formatter);
    appender.setFile(settings.getCurrentLogFilename());
    appender.setPrudent(false);

    addThresholdFilter(appender, settings.getThreshold());

    if (settings.isArchive()) {

        final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
                new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
        final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();

        triggeringPolicy.setContext(context);
        triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);

        rollingPolicy.setContext(context);
        rollingPolicy.setFileNamePattern(settings.getArchivedLogFilenamePattern());
        rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(triggeringPolicy);
        rollingPolicy.setMaxHistory(settings.getArchivedFileCount());

        ((RollingFileAppender<ILoggingEvent>)appender).setRollingPolicy(rollingPolicy);
        ((RollingFileAppender<ILoggingEvent>)appender).setTriggeringPolicy(triggeringPolicy);

        rollingPolicy.setParent(appender);
        rollingPolicy.start();
    }

    appender.stop();
    appender.start();

    return appender;
}
 
開發者ID:Metrink,項目名稱:croquet,代碼行數:45,代碼來源:CroquetLoggingFactory.java

示例8: buildFileAppender

import ch.qos.logback.core.FileAppender; //導入方法依賴的package包/類
public static FileAppender<ILoggingEvent> buildFileAppender(FileLoggingConfiguration file,
                                                            LoggerContext context) {
    final LogFormatter formatter = new LogFormatter(context, file.getTimeZone());
    for (String format : file.getLogFormat().asSet()) {
        formatter.setPattern(format);
    }
    formatter.start();

    final FileAppender<ILoggingEvent> appender =
            file.isArchive() ? new RollingFileAppender<ILoggingEvent>() :
                    new FileAppender<ILoggingEvent>();

    appender.setAppend(true);
    appender.setContext(context);
    appender.setLayout(formatter);
    appender.setFile(file.getCurrentLogFilename());
    appender.setPrudent(false);

    addThresholdFilter(appender, file.getThreshold());

    if (file.isArchive()) {

        final DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent> triggeringPolicy =
                new DefaultTimeBasedFileNamingAndTriggeringPolicy<ILoggingEvent>();
        triggeringPolicy.setContext(context);

        final TimeBasedRollingPolicy<ILoggingEvent> rollingPolicy = new TimeBasedRollingPolicy<ILoggingEvent>();
        rollingPolicy.setContext(context);
        rollingPolicy.setFileNamePattern(file.getArchivedLogFilenamePattern());
        rollingPolicy.setTimeBasedFileNamingAndTriggeringPolicy(
                triggeringPolicy);
        triggeringPolicy.setTimeBasedRollingPolicy(rollingPolicy);
        rollingPolicy.setMaxHistory(file.getArchivedFileCount());

        ((RollingFileAppender<ILoggingEvent>) appender).setRollingPolicy(rollingPolicy);
        ((RollingFileAppender<ILoggingEvent>) appender).setTriggeringPolicy(triggeringPolicy);

        rollingPolicy.setParent(appender);
        rollingPolicy.start();
    }

    appender.stop();
    appender.start();

    return appender;
}
 
開發者ID:wotifgroup,項目名稱:grails-lightweight-deploy,代碼行數:47,代碼來源:LogbackFactory.java


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