Package org.apache.log4j

Examples of org.apache.log4j.Appender


      ConsoleAppender consoleAppender = null;
      for(Enumeration<Appender> e = (Enumeration<Appender>)rootLogger.getAllAppenders();
      e.hasMoreElements();) {

        Appender a = e.nextElement();
        if(a instanceof ConsoleAppender) {
          consoleAppender = (ConsoleAppender)a;
          break;
        }
      }
View Full Code Here


    }

    void addAppender(String appenderClass, String appenderName)
    {
        _log.debug("addAppender called with " + appenderClass + ", " + appenderName);
        Appender appender = (Appender) OptionConverter.instantiateByClassName(
                appenderClass,
                org.apache.log4j.Appender.class,
                null);
        appender.setName(appenderName);
        _logger.addAppender(appender);

    }
View Full Code Here

    void appenderMBeanRegistration()
    {
        Enumeration enumeration = _logger.getAllAppenders();
        while (enumeration.hasMoreElements())
        {
            Appender appender = (Appender) enumeration.nextElement();
            registerAppenderMBean(appender);
        }
    }
View Full Code Here

            @Override
            public String apply(LoggingEvent loggingEvent) {
                return loggingEvent.getRenderedMessage();
            }
        });
        Appender appender = new AppenderSkeleton(true) {
            @Override
            protected void append(LoggingEvent event) {
                if (event.getLevel().equals(Level.ERROR)) {
                    events.add(event);
                }
            }

            @Override
            public void close() {

            }

            @Override
            public boolean requiresLayout() {
                return false;
            }
        };
        appender.setLayout(new SimpleLayout());
        Logger logger = Logger.getLogger("org.apache.curator");
        logger.addAppender(appender);

        // Check that we can intercept error log messages from the client
        CuratorFramework clientTestLogSetup = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
View Full Code Here

    }
    public synchronized Handler[] getHandlers() {
        List<Handler> ret = new ArrayList<Handler>();
        Enumeration en = log.getAllAppenders();
        while (en.hasMoreElements()) {
            Appender ap = (Appender)en.nextElement();
            if (ap instanceof HandlerWrapper) {
                ret.add(((HandlerWrapper)ap).getHandler());
            }
        }
        return ret.toArray(new Handler[ret.size()]);
View Full Code Here

   }

   @Test
   public void test1() throws Throwable
   {
      Appender appender = mock(Appender.class);
      doThrow(new AssertionError("logging WEIRDNESS IN AOP")).when(appender).doAppend(weirdnessInAOP());
      org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(InjectInterceptorsFactory.class);
      logger.addAppender(appender);
      try
      {
View Full Code Here

    }
    public synchronized Handler[] getHandlers() {
        List<Handler> ret = new ArrayList<Handler>();
        Enumeration en = log.getAllAppenders();
        while (en.hasMoreElements()) {
            Appender ap = (Appender)en.nextElement();
            if (ap instanceof HandlerWrapper) {
                ret.add(((HandlerWrapper)ap).getHandler());
            }
        }
        return ret.toArray(new Handler[ret.size()]);
View Full Code Here

  }

  private static void addAppenders(Logger logger, Set<Appender> allAppenders) {
      Enumeration appenders = logger.getAllAppenders();
      while (appenders.hasMoreElements()) {
          Appender appender = (Appender) appenders.nextElement();
          allAppenders.add(appender);
      }
  }
View Full Code Here

  }

  public static FileAppender getFileAppender(String name, LoggerRepository repository) {
      Set allAppenders = getAllAppenders(repository);
    for (Object allAppender : allAppenders) {
      Appender appender = (Appender) allAppender;
      if (appender instanceof FileAppender) {
        FileAppender fileAppender = (FileAppender) appender;
        if (fileAppender.getName() != null
            && fileAppender.getName().equals(name)) {
          return fileAppender;
View Full Code Here

    public static boolean registerFileAppender(String module, String name, String logFile, long maxSize, int backupIdx, String pattern) {
        Logger logger = Logger.getLogger(module);
        boolean found = false;

        Appender foundAppender = logger.getAppender(name);
        if (foundAppender == null) {
            Enumeration<Logger> currentLoggerEnum = UtilGenerics.cast(Logger.getRootLogger().getLoggerRepository().getCurrentLoggers());
            while (currentLoggerEnum.hasMoreElements() && foundAppender == null) {
                Logger log = currentLoggerEnum.nextElement();
                foundAppender = log.getAppender(name);
View Full Code Here

TOP

Related Classes of org.apache.log4j.Appender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.