public void begin(InterpretationContext ec, String name, Attributes attributes) { inError = false; LoggerContext loggerContext = (LoggerContext) this.context; root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); String levelStr = ec.subst(attributes.getValue(ActionConst.LEVEL_ATTRIBUTE)); if (!OptionHelper.isEmpty(levelStr)) { Level level = Level.toLevel(levelStr); addInfo("Setting level of ROOT logger to " + level); root.setLevel(level); } ec.pushObject(root); }
public void begin(InterpretationContext ec, String name, Attributes attributes) { Object o = ec.peekObject(); if (!(o instanceof Logger)) { inError = true; addError("For element <level>, could not find a logger at the top of execution stack."); return; } Logger l = (Logger) o; String loggerName = l.getName(); String levelStr = ec.subst(attributes.getValue(ActionConst.VALUE_ATTR)); // addInfo("Encapsulating logger name is [" + loggerName // + "], level value is [" + levelStr + "]."); if (ActionConst.INHERITED.equalsIgnoreCase(levelStr) || ActionConst.NULL.equalsIgnoreCase(levelStr)) { l.setLevel(null); } else { l.setLevel(Level.toLevel(levelStr, Level.DEBUG)); } addInfo(loggerName + " level set to " + l.getLevel()); }
String loggerName = ec.subst(attributes.getValue(NAME_ATTRIBUTE)); String levelStr = ec.subst(attributes.getValue(LEVEL_ATTRIBUTE)); String additivityStr = ec.subst(attributes.getValue(ActionConst.ADDITIVITY_ATTRIBUTE)); if (!OptionHelper.isEmpty(additivityStr)) { boolean additive = OptionHelper.toBoolean(additivityStr, true);
public void body(InterpretationContext ec, String body) { String finalBody = ec.subst(body); addInfo("Setting logger context name as [" + finalBody + "]"); try { context.setName(finalBody); } catch (IllegalStateException e) { addError("Failed to rename context [" + context.getName() + "] as [" + finalBody + "]", e); } }
public void begin(InterpretationContext ic, String name, Attributes attributes) { threshold = System.currentTimeMillis(); // See LOGBACK-527 (the system property is looked up first. Thus, it overrides // the equivalent property in the config file. This reversal of scope priority is justified // by the use case: the admin trying to chase rogue config file String debugAttrib = getSystemProperty(DEBUG_SYSTEM_PROPERTY_KEY); if (debugAttrib == null) { debugAttrib = ic.subst(attributes.getValue(INTERNAL_DEBUG_ATTR)); } if (OptionHelper.isEmpty(debugAttrib) || debugAttrib.equalsIgnoreCase("false") || debugAttrib.equalsIgnoreCase("null")) { addInfo(INTERNAL_DEBUG_ATTR + " attribute not set"); } else { StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener()); } processScanAttrib(ic, attributes); LoggerContext lc = (LoggerContext) context; boolean packagingData = OptionHelper.toBoolean(ic.subst(attributes.getValue(PACKAGING_DATA_ATTR)), LoggerContext.DEFAULT_PACKAGING_DATA); lc.setPackagingDataEnabled(packagingData); if (EnvUtil.isGroovyAvailable()) { ContextUtil contextUtil = new ContextUtil(context); contextUtil.addGroovyPackages(lc.getFrameworkPackages()); } // the context is turbo filter attachable, so it is pushed on top of the // stack ic.pushObject(getContext()); }
void processScanAttrib(InterpretationContext ic, Attributes attributes) { String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR)); if (!OptionHelper.isEmpty(scanAttrib) && !"false".equalsIgnoreCase(scanAttrib)) { ScheduledExecutorService scheduledExecutorService = context.getScheduledExecutorService(); URL mainURL = ConfigurationWatchListUtil.getMainWatchURL(context); if (mainURL == null) { addWarn("Due to missing top level configuration file, reconfiguration on change (configuration file scanning) cannot be done."); return; } ReconfigureOnChangeTask rocTask = new ReconfigureOnChangeTask(); rocTask.setContext(context); context.putObject(CoreConstants.RECONFIGURE_ON_CHANGE_TASK, rocTask); String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR)); Duration duration = getDuration(scanAttrib, scanPeriodAttrib); if (duration == null) { return; } addInfo("Will scan for changes in [" + mainURL + "] "); // Given that included files are encountered at a later phase, the complete list of files // to scan can only be determined when the configuration is loaded in full. // However, scan can be active if mainURL is set. Otherwise, when changes are detected // the top level config file cannot be accessed. addInfo("Setting ReconfigureOnChangeTask scanning period to " + duration); ScheduledFuture<?> scheduledFuture = scheduledExecutorService.scheduleAtFixedRate(rocTask, duration.getMilliseconds(), duration.getMilliseconds(), TimeUnit.MILLISECONDS); context.addScheduledFuture(scheduledFuture); } }
public void body(InterpretationContext ec, String body) { String finalBody = ec.subst(body); // get the action data object pushed in isApplicable() method call IADataForBasicProperty actionData = (IADataForBasicProperty) actionDataStack.peek(); switch (actionData.aggregationType) { case AS_BASIC_PROPERTY: actionData.parentBean.setProperty(actionData.propertyName, finalBody); break; case AS_BASIC_PROPERTY_COLLECTION: actionData.parentBean .addBasicProperty(actionData.propertyName, finalBody); } }
URL getInputURL(InterpretationContext ec, Attributes attributes) { String fileAttribute = attributes.getValue(FILE_ATTR); String urlAttribute = attributes.getValue(URL_ATTR); String resourceAttribute = attributes.getValue(RESOURCE_ATTR); if (!OptionHelper.isEmpty(fileAttribute)) { this.attributeInUse = ec.subst(fileAttribute); return filePathAsURL(attributeInUse); } if (!OptionHelper.isEmpty(urlAttribute)) { this.attributeInUse = ec.subst(urlAttribute); return attributeToURL(attributeInUse); } if (!OptionHelper.isEmpty(resourceAttribute)) { this.attributeInUse = ec.subst(resourceAttribute); return resourceAsURL(attributeInUse); } // given previous checkAttributes() check we cannot reach this line throw new IllegalStateException("A URL stream should have been returned"); }
public void begin(InterpretationContext ec, String name, Attributes attributes) { inError = false; LoggerContext loggerContext = (LoggerContext) this.context; root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME); String levelStr = ec.subst(attributes.getValue(ActionConst.LEVEL_ATTRIBUTE)); if (!OptionHelper.isEmpty(levelStr)) { Level level = Level.toLevel(levelStr); addInfo("Setting level of ROOT logger to " + level); root.setLevel(level); } ec.pushObject(root); }
public void begin(InterpretationContext ec, String name, Attributes attributes) { Object o = ec.peekObject(); if (!(o instanceof Logger)) { inError = true; addError("For element <level>, could not find a logger at the top of execution stack."); return; } Logger l = (Logger) o; String loggerName = l.getName(); String levelStr = ec.subst(attributes.getValue(ActionConst.VALUE_ATTR)); //addInfo("Encapsulating logger name is [" + loggerName // + "], level value is [" + levelStr + "]."); if (ActionConst.INHERITED.equalsIgnoreCase(levelStr) || ActionConst.NULL.equalsIgnoreCase(levelStr)) { l.setLevel(null); } else { l.setLevel(Level.toLevel(levelStr, Level.DEBUG)); } addInfo(loggerName + " level set to " + l.getLevel()); }
public void begin( InterpretationContext ec, String localName, Attributes attributes) { String name = attributes.getValue(NAME_ATTRIBUTE); String value = attributes.getValue(VALUE_ATTRIBUTE); if (name == null) { inError = true; addError(NO_NAME); return; } if (value == null) { inError = true; addError(NO_VALUE); return; } // remove both leading and trailing spaces value = value.trim(); Object o = ec.peekObject(); PropertySetter propSetter = new PropertySetter(o); propSetter.setContext(context); value = ec.subst(value); // allow for variable substitution for name as well name = ec.subst(name); //getLogger().debug( // "In ParamAction setting parameter [{}] to value [{}].", name, value); propSetter.setProperty(name, value); }
public void body(InterpretationContext ec, String body) { String finalBody = ec.subst(body); addInfo("Setting logger context name as [" + finalBody + "]"); try { context.setName(finalBody); } catch (IllegalStateException e) { addError("Failed to rename context [" + context.getName() + "] as [" + finalBody + "]", e); } }
String loggerName = ec.subst(attributes.getValue(NAME_ATTRIBUTE)); String levelStr = ec.subst(attributes.getValue(LEVEL_ATTRIBUTE)); String additivityStr = ec.subst(attributes.getValue(ActionConst.ADDITIVITY_ATTRIBUTE)); if (!OptionHelper.isEmpty(additivityStr)) { boolean additive = OptionHelper.toBoolean(additivityStr, true);
void processScanAttrib(InterpretationContext ic, Attributes attributes) { String scanAttrib = ic.subst(attributes.getValue(SCAN_ATTR)); if (!OptionHelper.isEmpty(scanAttrib) && !"false".equalsIgnoreCase(scanAttrib)) { ReconfigureOnChangeFilter rocf = new ReconfigureOnChangeFilter(); rocf.setContext(context); String scanPeriodAttrib = ic.subst(attributes.getValue(SCAN_PERIOD_ATTR)); if (!OptionHelper.isEmpty(scanPeriodAttrib)) { try { Duration duration = Duration.valueOf(scanPeriodAttrib); rocf.setRefreshPeriod(duration.getMilliseconds()); addInfo("Setting ReconfigureOnChangeFilter scanning period to " + duration); } catch (NumberFormatException nfe) { addError("Error while converting [" + scanAttrib + "] to long", nfe); } } rocf.start(); LoggerContext lc = (LoggerContext) context; addInfo("Adding ReconfigureOnChangeFilter as a turbo filter"); lc.addTurboFilter(rocf); } }
public void begin(InterpretationContext ic, String name, Attributes attributes) { threshold = System.currentTimeMillis(); // See LOGBACK-527 (the system property is looked up first. Thus, it overrides // the equivalent property in the config file. This reversal of scope priority is justified // by the use case: the admin trying to chase rogue config file String debugAttrib = getSystemProperty(DEBUG_SYSTEM_PROPERTY_KEY); if (debugAttrib == null) { debugAttrib = ic.subst(attributes.getValue(INTERNAL_DEBUG_ATTR)); } if (OptionHelper.isEmpty(debugAttrib) || debugAttrib.equalsIgnoreCase("false") || debugAttrib.equalsIgnoreCase("null")) { addInfo(INTERNAL_DEBUG_ATTR + " attribute not set"); } else { OnConsoleStatusListener.addNewInstanceToContext(context); } processScanAttrib(ic, attributes); ContextUtil contextUtil = new ContextUtil(context); contextUtil.addHostNameAsProperty(); if(EnvUtil.isGroovyAvailable()) { LoggerContext lc = (LoggerContext) context; contextUtil.addGroovyPackages(lc.getFrameworkPackages()); } // the context is turbo filter attachable, so it is pushed on top of the // stack ic.pushObject(getContext()); }
String appenderName = ec.subst(attributes.getValue(ActionConst.REF_ATTRIBUTE));
String appenderName = ec.subst(attributes.getValue(NAME_ATTRIBUTE));
className = ec.subst(className);