org.apache.logging.log4j.core.config.Configuration.getStrSubstitutor()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.apache.logging.log4j.core.config.Configuration.getStrSubstitutor()方法的一些代码示例,展示了Configuration.getStrSubstitutor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.getStrSubstitutor()方法的具体详情如下:
包路径:org.apache.logging.log4j.core.config.Configuration
类名称:Configuration
方法名:getStrSubstitutor

Configuration.getStrSubstitutor介绍

暂无

代码示例

代码示例来源:origin: apache/geode

static boolean isUsingGemFireDefaultConfig() {
 Configuration configuration = getConfiguration();
 StrSubstitutor strSubstitutor = configuration.getStrSubstitutor();
 StrLookup variableResolver = strSubstitutor.getVariableResolver();
 String value = variableResolver.lookup(GEODE_DEFAULT_PROPERTY);
 return "true".equals(value);
}

代码示例来源:origin: rhwayfun/spring-boot-learning-examples

public static String getLoggerProperty(String propertyName) {
  final LoggerContext loggerContext = (LoggerContext) LogManager.getContext(true);
  final Configuration config = loggerContext.getConfiguration();
  final StrSubstitutor strSubstitutor = config.getStrSubstitutor();
  final StrLookup variableResolver = strSubstitutor.getVariableResolver();
  return variableResolver.lookup(propertyName);
}

代码示例来源:origin: Meituan-Dianping/Zebra

return new ZebraRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, config.getStrSubstitutor());

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * {@inheritDoc}
 */
@Override
public void format(final Object obj, final StringBuilder output) {
  output.append(substitute ? config.getStrSubstitutor().replace(literal) : literal);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
  toAppendTo.append(substitute ? config.getStrSubstitutor().replace(event, literal) : literal);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * {@inheritDoc}
 */
@Override
public void format(final StringBuilder output, final Object... objects) {
  output.append(substitute ? config.getStrSubstitutor().replace(literal) : literal);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public DirectWriteRolloverStrategy build() {
  int maxIndex = Integer.MAX_VALUE;
  if (maxFiles != null) {
    maxIndex = Integer.parseInt(maxFiles);
    if (maxIndex < 0) {
      maxIndex = Integer.MAX_VALUE;
    } else if (maxIndex < 2) {
      LOGGER.error("Maximum files too small. Limited to " + DEFAULT_MAX_FILES);
      maxIndex = DEFAULT_MAX_FILES;
    }
  }
  final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION);
  return new DirectWriteRolloverStrategy(maxIndex, compressionLevel, config.getStrSubstitutor(),
      customActions, stopCustomActionsOnError, tempCompressedFilePattern);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

return new DefaultRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, config.getStrSubstitutor(),
    customActions, stopCustomActionsOnError, tempCompressedFilePattern);

代码示例来源:origin: org.apache.geode/gemfire-core

public static boolean isUsingGemFireDefaultConfig() {
 final Configuration config = ((org.apache.logging.log4j.core.Logger)
   LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
 
 final StrSubstitutor sub = config.getStrSubstitutor();
 final StrLookup resolver = sub.getVariableResolver();
 
 final String value = resolver.lookup(GEMFIRE_DEFAULT_PROPERTY);
 
 return "true".equals(value);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public PatternFormatter[] getFormatters(final LogEvent event) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.putAll(configuration.getProperties());
  bindings.put("substitutor", configuration.getStrSubstitutor());
  bindings.put("logEvent", event);
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  if (object == null) {
    return defaultFormatters;
  }
  final PatternFormatter[] patternFormatter = formatterMap.get(object.toString());
  return patternFormatter == null ? defaultFormatters : patternFormatter;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Rewrite the event.
 * @param source a logging event that may be returned or
 * used to create a new logging event.
 * @return The LogEvent after rewriting.
 */
@Override
public LogEvent rewrite(final LogEvent source) {
  final Map<String, String> props = new HashMap<>(source.getContextData().toMap());
  for (final Map.Entry<Property, Boolean> entry : properties.entrySet()) {
    final Property prop = entry.getKey();
    props.put(prop.getName(), entry.getValue().booleanValue() ?
      config.getStrSubstitutor().replace(prop.getValue()) : prop.getValue());
  }
  final LogEvent result = new Log4jLogEvent.Builder(source).setContextMap(props).build();
  return result;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public Result filter(final LogEvent event) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.put("logEvent", event);
  bindings.putAll(configuration.getProperties());
  bindings.put("substitutor", configuration.getStrSubstitutor());
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public PosixViewAttributeAction build() {
  if (Strings.isEmpty(basePath)) {
    LOGGER.error("Posix file attribute view action not valid because base path is empty.");
    return null;
  }
  if (filePermissions == null && Strings.isEmpty(filePermissionsString)
        && Strings.isEmpty(fileOwner) && Strings.isEmpty(fileGroup)) {
    LOGGER.error("Posix file attribute view not valid because nor permissions, user or group defined.");
    return null;
  }
  if (!FileUtils.isFilePosixAttributeViewSupported()) {
    LOGGER.warn("Posix file attribute view defined but it is not supported by this files system.");
    return null;
  }
  return new PosixViewAttributeAction(basePath, followLinks, maxDepth, pathConditions,
      subst != null ? subst : configuration.getStrSubstitutor(),
      filePermissions != null ? filePermissions :
            filePermissionsString != null ? PosixFilePermissions.fromString(filePermissionsString) : null,
      fileOwner,
      fileGroup);
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg,
           final Throwable t) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.put("logger", logger);
  bindings.put("level", level);
  bindings.put("marker", marker);
  bindings.put("message", msg);
  bindings.put("parameters", null);
  bindings.put("throwable", t);
  bindings.putAll(configuration.getProperties());
  bindings.put("substitutor", configuration.getStrSubstitutor());
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public void append(LogEvent event) {
  if (rewritePolicy != null) {
    event = rewritePolicy.rewrite(event);
  }
  final String pattern = routes.getPattern(event, scriptStaticVariables);
  final String key = pattern != null ? configuration.getStrSubstitutor().replace(event, pattern) : defaultRoute.getKey();
  final AppenderControl control = getControl(key, event);
  if (control != null) {
    control.callAppender(event);
  }
  if (purgePolicy != null) {
    purgePolicy.update(key, event);
  }
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final String msg,
           final Object... params) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.put("logger", logger);
  bindings.put("level", level);
  bindings.put("marker", marker);
  bindings.put("message", new SimpleMessage(msg));
  bindings.put("parameters", params);
  bindings.put("throwable", null);
  bindings.putAll(configuration.getProperties());
  bindings.put("substitutor", configuration.getStrSubstitutor());
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

@Override
public Result filter(final Logger logger, final Level level, final Marker marker, final Object msg,
           final Throwable t) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.put("logger", logger);
  bindings.put("level", level);
  bindings.put("marker", marker);
  bindings.put("message", msg instanceof String ? new SimpleMessage((String)msg) : new ObjectMessage(msg));
  bindings.put("parameters", null);
  bindings.put("throwable", t);
  bindings.putAll(configuration.getProperties());
  bindings.put("substitutor", configuration.getStrSubstitutor());
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  return object == null || !Boolean.TRUE.equals(object) ? onMismatch : onMatch;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

/**
 * Executes the script
 * 
 * @param baseDir
 * @param candidates
 * @return
 */
@SuppressWarnings("unchecked")
public List<PathWithAttributes> selectFilesToDelete(final Path basePath, final List<PathWithAttributes> candidates) {
  final SimpleBindings bindings = new SimpleBindings();
  bindings.put("basePath", basePath);
  bindings.put("pathList", candidates);
  bindings.putAll(configuration.getProperties());
  bindings.put("configuration", configuration);
  bindings.put("substitutor", configuration.getStrSubstitutor());
  bindings.put("statusLogger", LOGGER);
  final Object object = configuration.getScriptManager().execute(script.getName(), bindings);
  return (List<PathWithAttributes>) object;
}

代码示例来源:origin: ops4j/org.ops4j.pax.logging

? privateConfig.config.getStrSubstitutor().replace(event, prop.getValue()) //
    : prop.getValue();
contextData.putValue(prop.getName(), value);

代码示例来源:origin: ops4j/org.ops4j.pax.logging

config.getStrSubstitutor());

相关文章