ch.qos.logback.core.Appender.getName()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(40)

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

Appender.getName介绍

[英]Get the name of this appender. The name uniquely identifies the appender.
[中]获取此追加器的名称。该名称唯一标识追加器。

代码示例

代码示例来源:origin: alibaba/nacos

private static List<AppenderInfo> doGetLoggerAppenders(Iterator<Appender<ILoggingEvent>> appenders) {
    List<AppenderInfo> result = new ArrayList<AppenderInfo>();

    while (appenders.hasNext()) {
      AppenderInfo info = new AppenderInfo();
      Appender<ILoggingEvent> appender = appenders.next();
      info.setName(appender.getName());
      info.setType(appender.getClass().getName());
      if (appender instanceof FileAppender) {
        info.setFile(((FileAppender)appender).getFile());
      } else if (appender instanceof AsyncAppender) {
        AsyncAppender aa = (AsyncAppender)appender;
        Iterator<Appender<ILoggingEvent>> iter = aa.iteratorForAppenders();
        List<AppenderInfo> asyncs = doGetLoggerAppenders(iter);
        // 标明异步appender
        List<String> nestedNames = new ArrayList<String>();
        for (AppenderInfo a : asyncs) {
          nestedNames.add(a.getName());
          result.add(a);
        }
        info.withDetail("nestedNames", nestedNames);
      } else if (appender instanceof ConsoleAppender) {
        info.withDetail("target", ((ConsoleAppender)appender).getTarget());
      }
      result.add(info);
    }

    return result;
  }
}

代码示例来源:origin: dropwizard/dropwizard

protected Appender<E> wrapAsync(Appender<E> appender, AsyncAppenderFactory<E> asyncAppenderFactory, Context context) {
  final AsyncAppenderBase<E> asyncAppender = asyncAppenderFactory.build();
  if (asyncAppender instanceof AsyncAppender) {
    ((AsyncAppender) asyncAppender).setIncludeCallerData(includeCallerData);
  }
  asyncAppender.setQueueSize(queueSize);
  asyncAppender.setDiscardingThreshold(discardingThreshold);
  asyncAppender.setContext(context);
  asyncAppender.setName("async-" + appender.getName());
  asyncAppender.addAppender(appender);
  asyncAppender.setNeverBlock(neverBlock);
  asyncAppender.start();
  if (messageRate == null) {
    return asyncAppender;
  } else {
    return new ThrottlingAppenderWrapper<>(asyncAppender, messageRate.getQuantity(), messageRate.getUnit());
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Look for an attached appender named as <code>name</code>.
 * <p/>
 * <p> Return the appender with that name if in the list. Return null
 * otherwise.
 */
public Appender<E> getAppender(String name) {
 if (name == null) {
  return null;
 }
 Appender<E> found = null;
 for (Appender<E> appender : appenderList) {
  if (name.equals(appender.getName())) {
   return appender;
  }
 }
 return null;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  * Remove the appender with the name passed as parameter form the list of
  * appenders.
  */
 public boolean detachAppender(String name) {
  if (name == null) {
   return false;
  }
  boolean removed = false;
   for (Appender<E> a : appenderList) {
    if (name.equals((a).getName())) {
     removed = appenderList.remove(a);
     break;
    }
   }
  return removed;
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void addAppender(Appender<E> newAppender) {
 if (appenderCount == 0) {
  appenderCount++;
  addInfo("Attaching appender named ["+newAppender.getName()+"] to AsyncAppender.");
  aai.addAppender(newAppender);
 } else {
  addWarn("One and only one appender may be attached to AsyncAppender.");
  addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
 }
}

代码示例来源:origin: palantir/atlasdb

private Appender setLogLevelAndGetAppender(Level loglevel) {
  Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
  root.setLevel(loglevel);
  final Appender mockAppender = mock(Appender.class);
  when(mockAppender.getName()).thenReturn("MOCK");
  root.addAppender(mockAppender);
  return mockAppender;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
  * Once the children elements are also parsed, now is the time to activate the
  * appender options.
  */
 public void end(InterpretationContext ec, String name) {
  if (inError) {
   return;
  }

  if (appender instanceof LifeCycle) {
   ((LifeCycle) appender).start();
  }

  Object o = ec.peekObject();

  if (o != appender) {
   addWarn("The object at the of the stack is not the appender named ["
     + appender.getName() + "] pushed earlier.");
  } else {
   ec.popObject();
  }
 }
}

代码示例来源:origin: com.j256.cloudwatchlogbackappender/cloudwatchlogbackappender

@Override
public Appender<ILoggingEvent> getAppender(String name) {
  if (emergencyAppender != null && name != null && name.equals(emergencyAppender.getName())) {
    return emergencyAppender;
  } else {
    return null;
  }
}

代码示例来源:origin: dCache/dcache

public boolean isApplicableToAppender(Appender<?> appender)
  {
    return (_appender == null || _appender.equals(appender.getName()));
  }
}

代码示例来源:origin: j256/cloudwatch-logback-appender

@Override
public boolean detachAppender(String name) {
  if (emergencyAppender != null && emergencyAppender.getName().equals(name)) {
    emergencyAppender = null;
    return true;
  } else {
    return false;
  }
}

代码示例来源:origin: dCache/dcache

private List<String> getNames(List<Appender<ILoggingEvent>> appenders)
{
  List<String> result = new ArrayList<>(appenders.size());
  for (Appender<ILoggingEvent> appender: appenders) {
    result.add(appender.getName());
  }
  return result;
}

代码示例来源:origin: com.j256.cloudwatchlogbackappender/cloudwatchlogbackappender

@Override
public void addAppender(Appender<ILoggingEvent> appender) {
  if (emergencyAppender == null) {
    emergencyAppender = appender;
  } else {
    addWarn("One and only one appender may be attached to " + getClass().getSimpleName());
    addWarn("Ignoring additional appender named [" + appender.getName() + "]");
  }
}

代码示例来源:origin: org.opendaylight.controller/logback-config

private void removeBeforeAppenders(final Set<ch.qos.logback.classic.Logger> loggersBefore, final LoggerTO logger,
    final ch.qos.logback.classic.Logger logbackLogger, final Optional<Set<Appender<ILoggingEvent>>> appendersBefore) {
  if (appendersBefore.isPresent()) {
    for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
      logbackLogger.detachAppender(appenderBefore);
      appenderBefore.stop();
      LOG.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
          appenderBefore.getName());
    }
    loggersBefore.remove(logbackLogger);
  }
}

代码示例来源:origin: org.jresearch.logui/org.jresearch.logui.backend

@Nonnull
public static LogUiAppender toUi(@Nonnull final Appender<?> appender) {
  final LogUiAppender result = new LogUiAppender();
  result.setName(appender.getName());
  result.setClassName(appender.getClass().getName());
  return result;
}

代码示例来源:origin: tony19/logback-android

public void addAppender(Appender<E> newAppender) {
 if (appenderCount == 0) {
  appenderCount++;
  addInfo("Attaching appender named ["+newAppender.getName()+"] to AsyncAppender.");
  aai.addAppender(newAppender);
 } else {
  addWarn("One and only one appender may be attached to AsyncAppender.");
  addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
 }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/ch.qos.logback.core

public void addAppender(Appender<E> newAppender) {
 if (appenderCount == 0) {
  appenderCount++;
  addInfo("Attaching appender named ["+newAppender.getName()+"] to AsyncAppender.");
  aai.addAppender(newAppender);
 } else {
  addWarn("One and only one appender may be attached to AsyncAppender.");
  addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
 }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public void addAppender(Appender<E> newAppender) {
  if (appenderCount == 0) {
    appenderCount++;
    addInfo("Attaching appender named [" + newAppender.getName() + "] to AsyncAppender.");
    aai.addAppender(newAppender);
  } else {
    addWarn("One and only one appender may be attached to AsyncAppender.");
    addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
  }
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

public void addAppender(Appender<E> newAppender) {
  if (appenderCount == 0) {
    appenderCount++;
    addInfo("Attaching appender named [" + newAppender.getName() + "] to AsyncAppender.");
    aai.addAppender(newAppender);
  } else {
    addWarn("One and only one appender may be attached to AsyncAppender.");
    addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
  }
}

代码示例来源:origin: ch.qos.logback/core

public void addAppender(Appender<E> newAppender) {
 if (appenderCount == 0) {
  appenderCount++;
  addInfo("Attaching appender named ["+newAppender.getName()+"] to AsyncAppender.");
  aai.addAppender(newAppender);
 } else {
  addWarn("One and only one appender may be attached to AsyncAppender.");
  addWarn("Ignoring additional appender named [" + newAppender.getName() + "]");
 }
}

代码示例来源:origin: com.nhl.bootique.logback/bootique-logback

protected Appender<ILoggingEvent> asAsync(Appender<ILoggingEvent> appender, Context context) {
    final AsyncAppender asyncAppender = new AsyncAppender();
    asyncAppender.setIncludeCallerData(false);
    asyncAppender.setQueueSize(AsyncAppenderBase.DEFAULT_QUEUE_SIZE);
    asyncAppender.setDiscardingThreshold(-1);
    asyncAppender.setContext(context);
    asyncAppender.setName(appender.getName());
    asyncAppender.addAppender(appender);
    asyncAppender.start();
    return asyncAppender;
  }
}

相关文章