protected static void setupSidlogger(Level lvl) {
    if (!Level.OFF.equals(lvl)) {
      Filter bslf = new BoshSidLoggerFilter();

      Logger BoshConnectionManagerLogger = Logger.getLogger(BoshConnectionManager.class.getName());
      Logger BoshSessionLogger = Logger.getLogger(BoshSession.class.getName());

      if (BoshConnectionManagerLogger.getLevel() == null
          || BoshSessionLogger.getLevel() == null
          || BoshConnectionManagerLogger.getLevel().intValue() < lvl.intValue()) {
        BoshConnectionManagerLogger.setLevel(lvl);
        BoshConnectionManagerLogger.setFilter(bslf);
        BoshSessionLogger.setLevel(lvl);
        BoshSessionLogger.setFilter(bslf);

        BoshConnectionManagerLogger.getParent().setFilter(bslf);
      }

      try {
        if (null == sidFilehandler) {
          sidFilehandler = new FileHandler("logs/bosh_sid.log", 10000000, 5, false);
          sidFilehandler.setLevel(lvl);
          sidFilehandler.setFilter(bslf);
          BoshConnectionManagerLogger.getParent().addHandler(sidFilehandler);
        }
      } catch (IOException ex) {
        log.log(Level.CONFIG, "Error creating BOSH SID logger" + ex);
      }
    }
  }
  private void startInternal(BundleContext bundleContext) {
    // register the LogReaderService
    LogReaderServiceImpl logReader = new LogReaderServiceImpl(100);
    String readerServiceName = LogReaderService.class.getName();
    m_registrationLogReaderService =
        bundleContext.registerService(readerServiceName, logReader, null);

    // Tracking for the EventAdmin
    try {
      m_eventAdmin = new EventAdminTracker(bundleContext);
    } catch (NoClassDefFoundError e) {
      // If we hit a NoClassDefFoundError, this means the event admin package is not available,
      // so use a dummy poster
      m_eventAdmin =
          new EventAdminPoster() {
            public void postEvent(
                Bundle bundle,
                int level,
                LogEntry entry,
                String message,
                Throwable exception,
                ServiceReference sr,
                Map context) {}

            public void destroy() {}
          };
    }

    // register the Pax Logging service
    m_paxLogging =
        new PaxLoggingServiceImpl(bundleContext, logReader.getAccessDelegate(), m_eventAdmin);
    Hashtable<String, String> serviceProperties = new Hashtable<String, String>();
    serviceProperties.put(Constants.SERVICE_ID, "org.ops4j.pax.logging.configuration");
    serviceProperties.put(Constants.SERVICE_PID, CONFIGURATION_PID);
    m_RegistrationPaxLogging =
        bundleContext.registerService(LOG_SERVICE_INTERFACE_NAMES, m_paxLogging, serviceProperties);

    // Add a global handler for all JDK Logging (java.util.logging).
    if (!Boolean.valueOf(bundleContext.getProperty("org.ops4j.pax.logging.skipJUL"))) {
      LogManager manager = LogManager.getLogManager();
      manager.reset();

      // clear out old handlers
      Logger rootLogger = manager.getLogger("");
      Handler[] handlers = rootLogger.getHandlers();
      for (Handler handler : handlers) {
        rootLogger.removeHandler(handler);
      }

      rootLogger.setFilter(null);

      m_JdkHandler = new JdkHandler(m_paxLogging);
      rootLogger.addHandler(m_JdkHandler);
    }
    m_frameworkHandler = new FrameworkHandler(m_paxLogging);
    bundleContext.addBundleListener(m_frameworkHandler);
    bundleContext.addFrameworkListener(m_frameworkHandler);
    bundleContext.addServiceListener(m_frameworkHandler);
  }
  @Before
  public void setUp() {
    final Logger logger = Logger.getLogger(BundleEventLogger.class.getName());
    logger.setFilter(
        new Filter() {
          public boolean isLoggable(LogRecord record) {
            logRecord = record;
            return false;
          }
        });

    logger.setLevel(Level.FINEST);
  }
예제 #4
0
파일: Hawk.java 프로젝트: sycoso/Hawk
  public void onEnable() {
    log = getLogger();
    log.setFilter(this);

    HawkConfiguration.loadConfiguration(this);

    HawkPlayerListener player_listener = new HawkPlayerListener();
    HawkEntityListener entity_listener = new HawkEntityListener();

    getServer().getPluginManager().registerEvents(player_listener, this);
    getServer().getPluginManager().registerEvents(entity_listener, this);

    getServer().getScheduler().scheduleSyncRepeatingTask(this, new HawkTask(this), 1, 1);

    toLogger("loaded " + getDescription().getFullName());
  }
예제 #5
0
  public UkkonenSuffixTree() {
    logger =
        Logger.getLogger(
            "edu.psu.compbio.seqcode.gse.projects.chipseq.assembler.UkkonenSuffixTree");
    isLogging = true;
    minLogLevel = Level.SEVERE;
    logger.setFilter(new LoggingFilter());
    logger.addHandler(new LoggingHandler(System.err, false));
    logger.setUseParentHandlers(false);
    logger.setLevel(Level.SEVERE);

    logger.log(Level.FINE, "Logger setup complete.");

    strings = new Vector<TreeString>();
    terminal = '$';
    root = new TreeNode(null);
    totalStringEdges = new Vector<TreeEdge>();
    extState = null;
  }
예제 #6
0
  /**
   * This function initializes and returns the logger.
   *
   * @return The logger
   */
  protected static final Logger initializeLogger() {
    // get logger
    Logger logger = Logger.getLogger(FaxClient.class.getName());

    // enable all log events (fax4j logger filters out uneeded log events)
    logger.setLevel(Level.ALL);
    logger.setFilter(null);

    // enable to pass log events to parent loggers
    logger.setUseParentHandlers(true);

    // create handler
    Formatter formatter = new SimpleFormatter();
    Handler handler = new StreamHandler(System.out, formatter);

    // set filtering
    handler.setLevel(logger.getLevel());
    handler.setFilter(logger.getFilter());

    // add handler
    logger.addHandler(handler);

    return logger;
  }
예제 #7
0
 // static block
 static {
   LOGGER.setFilter(new FilterAllLogs());
 }
예제 #8
0
 /** @see java.util.logging.Logger#setFilter(java.util.logging.Filter) */
 @Override
 public void setFilter(Filter newFilter) throws SecurityException {
   delegate.setFilter(newFilter);
 }