Java 类org.apache.log4j.varia.DenyAllFilter 实例源码

项目:AcademicTorrents-Downloader    文件:ConsoleInput.java   
/**
     * Simple constructor to allow other components to use the console commands such as "set"
     * @param con
     * @param _azureus_core
     * @param _out
     */

public ConsoleInput(AzureusCore _azureus_core, PrintStream _out )
{
    super( "" );
    this.out = _out;
    this.azureus_core   = _azureus_core;
    this.userProfile    = UserProfile.DEFAULT_USER_PROFILE;
    this.controlling    = false;
    this.br             = new CommandReader( new InputStreamReader( new ByteArrayInputStream(new byte[0])));

    if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
      Appender app;
      app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
      app.setName("ConsoleAppender");
      app.addFilter( new DenyAllFilter() );  //'log off' by default
      Logger.getRootLogger().addAppender(app);
    }

    initialise();
}
项目:cacheonix-core    文件:LevelMatchFilterTestCase.java   
public void accept() throws Exception {

  // set up appender
  Layout layout = new SimpleLayout();
  Appender appender = new FileAppender(layout, ACCEPT_FILE, false);

  // create LevelMatchFilter
  LevelMatchFilter matchFilter = new LevelMatchFilter();

   // attach match filter to appender
  appender.addFilter(matchFilter);

  // attach DenyAllFilter to end of filter chain to deny neutral
  // (non matching) messages
  appender.addFilter(new DenyAllFilter());

  // set appender on root and set level to debug
  root.addAppender(appender);
  root.setLevel(Level.TRACE);

  Level[] levelArray = new Level[] {Level.TRACE, Level.DEBUG, Level.INFO, Level.WARN, 
              Level.ERROR, Level.FATAL};
  for (int x = 0; x < levelArray.length; x++) {
    // set the level to match
    matchFilter.setLevelToMatch(levelArray[x].toString());
    common("pass " + x + "; filter set to accept only " 
    + levelArray[x].toString() + " msgs");
  }

  Transformer.transform(ACCEPT_FILE, ACCEPT_FILTERED, new LineNumberFilter());
  assertTrue(Compare.compare(ACCEPT_FILTERED, ACCEPT_WITNESS));
}
项目:AcademicTorrents-Downloader    文件:Main.java   
public static void initRootLogger() {
  if (Logger.getRootLogger().getAppender("ConsoleAppender")==null) {
    Appender app;
    app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
    app.setName("ConsoleAppender");
    app.addFilter( new DenyAllFilter() );  //'log off' by default
    Logger.getRootLogger().addAppender(app);
  }
}
项目:JServer    文件:StandaloneFileAppenderComponent.java   
/**
 */
private void init()
{
   super.setDefaultLayoutPattern(DEFAULT_LAYOUT_PATTERN);
   super.setAutoFlushMode(true);
   // Create a DenyAllFilter to prevent the StandaloneFileAppenderComponent from receiving general log 
   // messages, if added to a LogManager.
   super.addFilter(new DenyAllFilter());
}
项目:daikon    文件:Log4j1Configurer.java   
static void configure() {
    final LogAppendersSet appendersSet = AuditConfiguration.LOG_APPENDER.getValue(LogAppendersSet.class);

    if (appendersSet == null || appendersSet.isEmpty()) {
        throw new AuditLoggingException("No audit appenders configured.");
    }

    if (appendersSet.size() > 1 && appendersSet.contains(LogAppenders.NONE)) {
        throw new AuditLoggingException("Invalid configuration: none appender is used with other simultaneously.");
    }

    final RewriteAppender auditAppender = new RewriteAppender();

    for (LogAppenders appender : appendersSet) {
        switch (appender) {
        case FILE:
            auditAppender.addAppender(rollingFileAppender());
            break;

        case SOCKET:
            auditAppender.addAppender(socketAppender());
            break;

        case CONSOLE:
            auditAppender.addAppender(consoleAppender());
            break;

        case HTTP:
            auditAppender.addAppender(httpAppender());
            break;

        case NONE:
            auditAppender.addFilter(new DenyAllFilter());
            break;

        default:
            throw new AuditLoggingException("Unknown appender " + appender);
        }
    }

    auditAppender.setRewritePolicy(new Log4j1EnricherPolicy());

    final Logger logger = Logger.getLogger(AuditConfiguration.ROOT_LOGGER.getString());

    logger.addAppender(auditAppender);
    logger.setAdditivity(false);
}