当前位置: 首页>>代码示例>>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;未经允许,请勿转载。