Package org.apache.log4j

Examples of org.apache.log4j.AppenderSkeleton


        assertEquals(String.format("%d:%s", 2, sql), logged.get(0));
    }

    public void testLog4J() throws Exception
    {
        BasicConfigurator.configure(new AppenderSkeleton()
        {
            protected void append(LoggingEvent loggingEvent)
            {
                logged.add(loggingEvent.getRenderedMessage());
            }
View Full Code Here


    /**
     * We add a simple appender to the MessageCenter logger
     * so that each message is displayed in the Status bar
     */
    MessageCenter.getInstance().getLogger().addAppender(
      new AppenderSkeleton() {
        protected void append(LoggingEvent event) {
          getStatusBar().setMessage(event.getMessage().toString());
        }

        public void close() {
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

    /**
     * We add a simple appender to the MessageCenter logger
     * so that each message is displayed in the Status bar
     */
    MessageCenter.getInstance().getLogger().addAppender(
      new AppenderSkeleton() {
        protected void append(LoggingEvent event) {
          getStatusBar().setMessage(event.getMessage().toString());
        }

        public void close() {
View Full Code Here

                memoryAppender.activateOptions();
            }

            // normally all the appenders inherit from AppenderSkelton
            if (appender instanceof AppenderSkeleton) {
                AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appender;
                if (appenderSkeleton.getThreshold() != null) {
                    appenderResource.addProperty(LoggingConstants.AppenderProperties.THRESHOLD,
                            appenderSkeleton.getThreshold().toString());
                } else {
                    appenderResource.addProperty(LoggingConstants.AppenderProperties.THRESHOLD, "DEBUG");
                }
            }
View Full Code Here

                syslogAppender.setFacility(facility);
            }

            // set the threshold
            if (appender instanceof AppenderSkeleton) {
                AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appender;
                appenderSkeleton.setThreshold(Level.toLevel(threshold));
                appenderSkeleton.activateOptions();
            }
        }
    }
View Full Code Here

        }

        Layout patternLayout = new PatternLayout(logPattern);
        for(Appender appender:appenderSet){
            if (appender instanceof AppenderSkeleton) {
                AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appender;
                appenderSkeleton.setThreshold(systemLevel);
                appenderSkeleton.setLayout(patternLayout);
                appenderSkeleton.activateOptions();
            }
        }

        // update the appender data stored in the registry
        Collection appenderCollection = registryManager.getAppenders();
View Full Code Here

            Layout layout = targetAppender.getLayout();
            if (layout instanceof PatternLayout) {
                appenderData.setPattern(((PatternLayout) layout).getConversionPattern());
            }
            if (targetAppender instanceof AppenderSkeleton) {          // normally all the appenders inherit from AppenderSkelton
                AppenderSkeleton appender = (AppenderSkeleton) targetAppender;
                Priority priority = appender.getThreshold();
                if (priority != null) {
                    appenderData.setThreshold(priority.toString());
                } else {
                    appender.setThreshold(Level.toLevel(Priority.DEBUG_INT));
                    appenderData.setThreshold("DEBUG");
                }
            }
            if (targetAppender instanceof SyslogAppender) { //NOTE: Don't make this an else if
                SyslogAppender appender = (SyslogAppender) targetAppender;
                appenderData.setIsSysLogAppender(true);
                appenderData.setFacility(appender.getFacility());
                appenderData.setSysLogHost(appender.getSyslogHost());
            } else if (targetAppender instanceof FileAppender) {
                appenderData.setIsFileAppender(true);
                appenderData.setLogFile(((FileAppender) targetAppender).getFile());
            }
        }
View Full Code Here

        logger.setLevel(systemLevel);
      }

      for (Appender appender : appenderSet) {
        if (appender instanceof AppenderSkeleton) {
          AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appender;
          appenderSkeleton.setThreshold(systemLevel);
          appenderSkeleton.activateOptions();
        }
      }
    }

    // Update the logger data according to the data stored in the registry.
    Collection loggerCollection = registryManager.getLoggers();
    if (loggerCollection != null) {
      String[] loggerResourcePaths = loggerCollection.getChildren();
      for (String loggerResourcePath : loggerResourcePaths) {
        String loggerName = loggerResourcePath.substring(LoggingConstants.LOGGERS.length());
        Logger logger = LogManager.getLogger(loggerName);
        Resource loggerResource = registryManager.getLogger(loggerName);
        if (loggerResource != null && logger != null) {
          logger.setLevel(Level.toLevel(loggerResource
              .getProperty(LoggingConstants.LoggerProperties.LOG_LEVEL)));
          logger.setAdditivity(Boolean.parseBoolean(loggerResource
              .getProperty(LoggingConstants.LoggerProperties.ADDITIVITY)));
        }
      }
    }

    // update the appender data according to data stored in database
    Collection appenderCollection = registryManager.getAppenders();
    if (appenderCollection != null) {
      String[] appenderResourcePaths = appenderCollection.getChildren();
      for (String appenderResourcePath : appenderResourcePaths) {
        String appenderName = appenderResourcePath.substring(LoggingConstants.APPENDERS
            .length());
        Appender appender = getAppenderFromSet(appenderSet, appenderName);
        Resource appenderResource = registryManager.getAppender(appenderName);
        if (appenderResource != null && appender != null) {
          if ((appender.getLayout() != null)
              && (appender.getLayout() instanceof PatternLayout)) {
            ((PatternLayout) appender.getLayout())
                .setConversionPattern(appenderResource
                    .getProperty(LoggingConstants.AppenderProperties.PATTERN));
          }
          if (appender instanceof FileAppender) {
            FileAppender fileAppender = ((FileAppender) appender);
            fileAppender.setFile(appenderResource
                .getProperty(LoggingConstants.AppenderProperties.LOG_FILE_NAME));
            fileAppender.activateOptions();
          }

          if (appender instanceof MemoryAppender) {
            MemoryAppender memoryAppender = (MemoryAppender) appender;
            memoryAppender.setCircularBuffer(new CircularBuffer(200));
            memoryAppender.activateOptions();
          }

          if (appender instanceof SyslogAppender) {
            SyslogAppender syslogAppender = (SyslogAppender) appender;
            syslogAppender.setSyslogHost(appenderResource
                .getProperty(LoggingConstants.AppenderProperties.SYS_LOG_HOST));
            syslogAppender.setFacility(appenderResource
                .getProperty(LoggingConstants.AppenderProperties.FACILITY));
          }

          if (appender instanceof AppenderSkeleton) {
            AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appender;
            appenderSkeleton.setThreshold(Level.toLevel(appenderResource
                .getProperty(LoggingConstants.AppenderProperties.THRESHOLD)));
            appenderSkeleton.activateOptions();
          }
        }
      }
    }
  }
View Full Code Here

    }

    final YWindowStart y = new YWindowStart();

    // add log
    final AppenderSkeleton aps = addLog(y);

    // load rest
    I18N.init();
    T.addOptions();
    YaFrame.init();
View Full Code Here

TOP

Related Classes of org.apache.log4j.AppenderSkeleton

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.