Package ch.qos.logback.core.status

Examples of ch.qos.logback.core.status.StatusManager


  public static void printIfErrorsOccured(Context context) {
    if (context == null) {
      throw new IllegalArgumentException("Context argument cannot be null");
    }

    StatusManager sm = context.getStatusManager();
    if (sm == null) {
      ps.println("WARN: Context named \"" + context.getName()
          + "\" has no status manager");
    } else {
      if (sm.getLevel() == ErrorStatus.ERROR) {
        print(sm);
      }
    }
  }
View Full Code Here


  public static void print(Context context) {
    if (context == null) {
      throw new IllegalArgumentException("Context argument cannot be null");
    }

    StatusManager sm = context.getStatusManager();
    if (sm == null) {
      ps.println("WARN: Context named \"" + context.getName()
          + "\" has no status manager");
    } else {
      print(sm);
View Full Code Here

  public static void main(String[] args) throws JoranException {
   
 
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    StatusManager statusManager = lc.getStatusManager();
    OnConsoleStatusListener onConsoleListener = new OnConsoleStatusListener();
    statusManager.add(onConsoleListener);

    Logger logger = LoggerFactory.getLogger("myApp");
    logger.info("Entering application.");

    Foo foo = new Foo();
View Full Code Here

    resetStatusListeners();
  }

 
  private void resetStatusListeners() {
    StatusManager sm = getStatusManager();
    for (StatusListener sl : sm.getCopyOfStatusListenerList()) {
      sm.remove(sl);
    }
  }
View Full Code Here

    }
  }

  private void multiplicityWarning(String resourceName, ClassLoader classLoader ) {
    List<URL> urlList = null;
    StatusManager sm = loggerContext.getStatusManager();
    try {
      urlList = Loader.getResourceOccurenceCount(resourceName, classLoader);
    } catch (IOException e) {
      sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]",
          loggerContext, e));
    }
    if(urlList != null && urlList.size() > 1) {
      sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.",
          loggerContext));
      for(URL url: urlList) {
      sm.add(new WarnStatus("Resource ["+resourceName+"] occurs at ["+url.toString()+"]",
          loggerContext));
      }
    }
  }
View Full Code Here

      }
    }
  }
 
  private void statusOnResourceSearch(String resourceName, ClassLoader classLoader, URL url) {
    StatusManager sm = loggerContext.getStatusManager();
    if (url == null) {
      sm.add(new InfoStatus("Could NOT find resource [" + resourceName + "]",
          loggerContext));
    } else {
      sm.add(new InfoStatus("Found resource [" + resourceName + "] at ["+url.toString()+"]",
          loggerContext));
      multiplicityWarning(resourceName, classLoader);
    }
  }
View Full Code Here

      throw new FileNotFoundException(errMsg);
    }
  }

  void addStatusListener(StatusListener statusListener) {
    StatusManager sm = loggerContext.getStatusManager();
    sm.add(statusListener);
  }
View Full Code Here

    StatusManager sm = loggerContext.getStatusManager();
    sm.add(statusListener);
  }

  void removeStatusListener(StatusListener statusListener) {
    StatusManager sm = loggerContext.getStatusManager();
    sm.remove(statusListener);
  }
View Full Code Here

  private String conventionalConfigFileName(String contextName) {
    return "logback-" + contextName + ".xml";
  }

  private URL findConfigFileURL(Context ctx, LoggerContext loggerContext) {
    StatusManager sm = loggerContext.getStatusManager();

    String jndiEntryForConfigResource = JNDIUtil.lookup(ctx,
        JNDI_CONFIGURATION_RESOURCE);
    // Do we have a dedicated configuration file?
    if (jndiEntryForConfigResource != null) {
      sm.add(new InfoStatus("Searching for [" + jndiEntryForConfigResource
          + "]", this));
      URL url = urlByResourceName(sm, jndiEntryForConfigResource);
      if (url == null) {
        String msg = "The jndi resource [" + jndiEntryForConfigResource
            + "] for context [" + loggerContext.getName()
            + "] does not lead to a valid file";
        sm.add(new WarnStatus(msg, this));
      }
      return url;
    } else {
      String resourceByConvention = conventionalConfigFileName(loggerContext
          .getName());
View Full Code Here

  public static void main(String[] args) throws JoranException {
   
 
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    StatusManager statusManager = lc.getStatusManager();
    OnConsoleStatusListener onConsoleListener = new OnConsoleStatusListener();
    statusManager.add(onConsoleListener);

    Logger logger = LoggerFactory.getLogger("myApp");
    logger.info("Entering application.");

    Foo foo = new Foo();
View Full Code Here

TOP

Related Classes of ch.qos.logback.core.status.StatusManager

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.