void addStatusListener(StatusListener statusListener) { StatusManager sm = loggerContext.getStatusManager(); sm.add(statusListener); }
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); } }
private void multiplicityWarning(String resourceName, ClassLoader classLoader) { Set<URL> urlSet = null; StatusManager sm = loggerContext.getStatusManager(); try { urlSet = Loader.getResources(resourceName, classLoader); } catch (IOException e) { sm.add(new ErrorStatus("Failed to get url list for resource [" + resourceName + "]", loggerContext, e)); } if (urlSet != null && urlSet.size() > 1) { sm.add(new WarnStatus("Resource [" + resourceName + "] occurs multiple times on the classpath.", loggerContext)); for (URL url : urlSet) { sm.add(new WarnStatus("Resource [" + resourceName + "] occurs at [" + url.toString() + "]", loggerContext)); } } } }
private static void addError(LoggerContext context, Object origin, String msg, Throwable t) { StatusManager sm = context.getStatusManager(); if (sm == null) { return; } sm.add(new ErrorStatus(msg, origin, t)); }
final void noAppenderDefinedWarning(final Logger logger) { if (noAppenderWarning++ == 0) { getStatusManager().add(new WarnStatus("No appenders present in context [" + getName() + "] for logger [" + logger.getName() + "].", logger)); } }
private URL urlByResourceName(StatusManager sm, String resourceName) { sm.add(new InfoStatus("Searching for [" + resourceName + "]", this)); URL url = Loader.getResource(resourceName, Loader.getTCL()); if (url != null) { return url; } return Loader.getResourceBySelfClassLoader(resourceName); }
public void configureByResource(URL url) throws JoranException { if (url == null) { throw new IllegalArgumentException("URL argument cannot be null"); } final String urlString = url.toString(); if (urlString.endsWith("groovy")) { if (EnvUtil.isGroovyAvailable()) { // avoid directly referring to GafferConfigurator so as to avoid // loading groovy.lang.GroovyObject . See also http://jira.qos.ch/browse/LBCLASSIC-214 GafferUtil.runGafferConfiguratorOn(loggerContext, this, url); } else { StatusManager sm = loggerContext.getStatusManager(); sm.add(new ErrorStatus("Groovy classes are not available on the class path. ABORTING INITIALIZATION.", loggerContext)); } } else if (urlString.endsWith("xml")) { JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(loggerContext); configurator.doConfigure(url); } else { throw new LogbackException("Unexpected filename extension of file [" + url.toString() + "]. Should be either .groovy or .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()); return urlByResourceName(sm, resourceByConvention); } }
public void addStatus(Status status) { if (sm != null) { sm.add(status); } }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
static void addStatus(Context context, Status s) { if (context == null) { System.out.println("Null context in " + ConfigurationWatchList.class.getName()); return; } StatusManager sm = context.getStatusManager(); if (sm == null) return; sm.add(s); }
public void addStatus(Status status) { if (context == null) { if (noContextWarning++ == 0) { System.out.println("LOGBACK: No context given for " + this); } return; } StatusManager sm = context.getStatusManager(); if (sm != null) { sm.add(status); } }
void addStatusListener(StatusListener statusListener) { StatusManager sm = loggerContext.getStatusManager(); sm.add(statusListener); }
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); } }
private static void addError(LoggerContext context, Object origin, String msg, Throwable t) { StatusManager sm = context.getStatusManager(); if (sm == null) { return; } sm.add(new ErrorStatus(msg, origin, t)); }
private static void initListener(LoggerContext loggerContext, StatusListener listener) { if (listener != null) { if(listener instanceof ContextAware) // LOGBACK-767 ((ContextAware) listener).setContext(loggerContext); if(listener instanceof LifeCycle) // LOGBACK-767 ((LifeCycle) listener).start(); loggerContext.getStatusManager().add(listener); } }
final void noAppenderDefinedWarning(final Logger logger) { if (noAppenderWarning++ == 0) { getStatusManager().add( new WarnStatus("No appenders present in context [" + getName() + "] for logger [" + logger.getName() + "].", logger)); } }
private URL urlByResourceName(StatusManager sm, String resourceName) { sm.add(new InfoStatus("Searching for [" + resourceName + "]", this)); URL url = Loader.getResource(resourceName, Loader.getTCL()); if (url != null) { return url; } return Loader.getResourceBySelfClassLoader(resourceName); }
/** * This utility method adds a new OnConsoleStatusListener to the context * passed as parameter. * * @param context * @since 1.0.1 */ static public void addNewInstanceToContext(Context context) { OnConsoleStatusListener onConsoleStatusListener = new OnConsoleStatusListener(); onConsoleStatusListener.setContext(context); onConsoleStatusListener.start(); context.getStatusManager().add(onConsoleStatusListener); }