public static LoggerContext getLoggerContext() { if (loggerContext == null) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } loggerContext = (LoggerContext)lcObject; } return loggerContext; } }
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"); } }
public void autoConfig() throws JoranException { StatusListenerConfigHelper.installIfAsked(loggerContext); URL url = findURLOfDefaultConfigurationFile(true); if (url != null) { configureByResource(url); } else { Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class); if (c != null) { try { c.setContext(loggerContext); c.configure(loggerContext); } catch (Exception e) { throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", c != null ? c.getClass() .getCanonicalName() : "null"), e); } } else { BasicConfigurator basicConfigurator = new BasicConfigurator(); basicConfigurator.setContext(loggerContext); basicConfigurator.configure(loggerContext); } } }
private LoggerContext getLoggerContext(Map<String, String> props) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } LoggerContext lc = (LoggerContext) lcObject; lc.reset(); for (Map.Entry<String, String> entry : props.entrySet()) { lc.putProperty(entry.getKey(), entry.getValue()); } return lc; }
private LoggerContext getLoggerContext(Map<String, String> props) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } LoggerContext lc = (LoggerContext) lcObject; lc.reset(); for (Map.Entry<String, String> entry : props.entrySet()) { lc.putProperty(entry.getKey(), entry.getValue()); } return lc; }
private LoggerContext getLoggerContext(Map<String, String> props) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } LoggerContext lc = (LoggerContext) lcObject; lc.reset(); for (Map.Entry<String, String> entry : props.entrySet()) { lc.putProperty(entry.getKey(), entry.getValue()); } return lc; }
public void configureByResource(URL url) throws JoranException { if (url == null) { throw new IllegalArgumentException("URL argument cannot be null"); } if (url.toString().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 (url.toString().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"); } }
public static LoggerContext getLoggerContext() { if (loggerContext == null) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } loggerContext = (LoggerContext)lcObject; } return loggerContext; } }
public static LoggerContext getLoggerContext() { if (loggerContext == null) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } loggerContext = (LoggerContext) lcObject; } return loggerContext; } }
public static LoggerContext getLoggerContext() { if (loggerContext == null) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } loggerContext = (LoggerContext) lcObject; } return loggerContext; } }
private LoggerContext getLoggerContext(Map<String, String> props) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } LoggerContext lc = (LoggerContext) lcObject; lc.reset(); for (Map.Entry<String, String> entry : props.entrySet()) { lc.putProperty(entry.getKey(), entry.getValue()); } return lc; }
private LoggerContext getLoggerContext(Map<String, String> props) { ILoggerFactory lcObject = LoggerFactory.getILoggerFactory(); if (!(lcObject instanceof LoggerContext)) { throw new LogbackException( "Expected LOGBACK binding with SLF4J, but another log system has taken the place: " + lcObject.getClass().getSimpleName()); } LoggerContext lc = (LoggerContext) lcObject; lc.reset(); for (Map.Entry<String, String> entry : props.entrySet()) { lc.putProperty(entry.getKey(), entry.getValue()); } return lc; }
@Override public void doAppend(E event) throws LogbackException { if (needSync) { try { sync(); } catch (IOException e) { throw new LogbackException("Sync failed. Cannot append event.", e); } } if (needFlush) { try { flush(); } catch (IOException e) { throw new LogbackException("Flush failed. Cannot append event.", e); } } super.doAppend(event); }
@Override public void doAppend(E event) throws LogbackException { if (needSync) { try { sync(); } catch (IOException e) { throw new LogbackException("Sync failed. Cannot append event.", e); } } if (needFlush) { try { flush(); } catch (IOException e) { throw new LogbackException("Flush failed. Cannot append event.", e); } } super.doAppend(event); }
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"); } }
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"); } }
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"); } }
@Override public void doAppend(ILoggingEvent eventObject) throws LogbackException { try { // logic from AppenderBase if (!this.started) { LOG.warn("Attempted to append to non started appender {}", this.getName()); return; } // logic from AppenderBase if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } String namespaceId = eventObject.getMDCPropertyMap().get(LocationManager.TAG_NAMESPACE_ID); if (namespaceId != null && !namespaceId.equals(NamespaceId.SYSTEM.getNamespace())) { LocationIdentifier logLocationIdentifier = locationManager.getLocationIdentifier(eventObject .getMDCPropertyMap()); rollover(logLocationIdentifier, eventObject); OutputStream locationOutputStream = locationManager.getLocationOutputStream(logLocationIdentifier, filePath); setOutputStream(locationOutputStream); writeOut(eventObject); } } catch (IllegalArgumentException iae) { // this shouldn't happen LOG.error("Unrecognized context ", iae); } catch (IOException ioe) { throw new LogbackException("Exception while appending event. ", ioe); } catch (RolloverFailure rolloverFailure) { throw new LogbackException("Exception while rolling over. ", rolloverFailure); } }
@Override public void doAppend(ILoggingEvent eventObject) throws LogbackException { try { // logic from AppenderBase if (!this.started) { LOG.warn("Attempted to append to non started appender {}", this.getName()); return; } // logic from AppenderBase if (getFilterChainDecision(eventObject) == FilterReply.DENY) { return; } String namespaceId = eventObject.getMDCPropertyMap().get(LocationManager.TAG_NAMESPACE_ID); if (namespaceId != null && !namespaceId.equals(NamespaceId.SYSTEM.getNamespace())) { LocationIdentifier logLocationIdentifier = locationManager.getLocationIdentifier(eventObject .getMDCPropertyMap()); rollover(logLocationIdentifier, eventObject); OutputStream locationOutputStream = locationManager.getLocationOutputStream(logLocationIdentifier, filePath); setOutputStream(locationOutputStream); writeOut(eventObject); } } catch (IllegalArgumentException iae) { // this shouldn't happen LOG.error("Unrecognized context ", iae); } catch (IOException ioe) { throw new LogbackException("Exception while appending event. ", ioe); } catch (RolloverFailure rolloverFailure) { throw new LogbackException("Exception while rolling over. ", rolloverFailure); } }
public void autoConfig() throws JoranException { StatusListenerConfigHelper.installIfAsked(loggerContext); URL url = findURLOfDefaultConfigurationFile(true); if (url != null) { configureByResource(url); } else { Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class); if (c != null) { try { c.setContext(loggerContext); c.configure(loggerContext); } catch (Exception e) { throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", c != null ? c.getClass() .getCanonicalName() : "null"), e); } } else { BasicConfigurator basicConfigurator = new BasicConfigurator(); basicConfigurator.setContext(loggerContext); basicConfigurator.configure(loggerContext); } } }