当前位置: 首页>>代码示例>>Java>>正文


Java SyslogAppender类代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.appender.SyslogAppender的典型用法代码示例。如果您正苦于以下问题:Java SyslogAppender类的具体用法?Java SyslogAppender怎么用?Java SyslogAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SyslogAppender类属于org.apache.logging.log4j.core.appender包,在下文中一共展示了SyslogAppender类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EmbeddedConfiguration

import org.apache.logging.log4j.core.appender.SyslogAppender; //导入依赖的package包/类
/**
 * Ctor. The configuration is built using instance of
 * {@link Spec}:
 * 
 * <ul>
 * <li>The name is set to {@link Spec#getName()}.
 * <li>Appenders from the parent object are cleared.
 * <li>{@link Appender}s are created
 * {@link #buildAppenders(Spec)}.
 * <li>{@link LoggerConfig}s are created using
 * {@link #buildLoggerConfigs(Spec)}.
 * <li>Every {@link LoggerConfig} is configured with its
 * {@link Appender} using
 * {@link #configureLoggerAppenders(Spec, Map, Map)}.
 * <li>Root loggers are configured.
 * </ul>
 * 
 * @param spec
 */
EmbeddedConfiguration(Spec spec) {
  super(ConfigurationSource.NULL_SOURCE);
  setName(spec.getName());

  // Clean up first
  getAppenders().clear();
  getRootLogger().getAppenders().clear();

  // Build Appenders
  final Map<String, Appender> appenders = buildAppenders(spec);
  final Map<String, SyslogAppender> syslogAppenders = buildSyslogAppenders(spec);

  // Build Logger Configs
  final Map<String, LoggerConfig> loggers = buildLoggerConfigs(spec);

  // Configure loggers with appenders
  configureLoggerAppenders(spec, appenders, loggers);

  // Configure root logger appenders
  configureRootLogger(spec, appenders, syslogAppenders);
}
 
开发者ID:nobeh,项目名称:log4j-configuration-builder,代码行数:41,代码来源:ConfigurationBuilder.java

示例2: buildSyslogAppenders

import org.apache.logging.log4j.core.appender.SyslogAppender; //导入依赖的package包/类
/**
 * @param spec
 * @return
 */
protected Map<String, SyslogAppender> buildSyslogAppenders(Spec spec) {
  Map<String, SyslogAppender> syslogAppenders = new HashMap<>();
  Collection<String> syslogAppenderNames = spec.getSyslogAppenderNames();
  for (String appenderName : syslogAppenderNames) {
    SyslogSpec sspec = spec.getSyslogSpec(appenderName);
    SyslogAppender syslogAppender =
        createSyslogAppender(sspec.name, sspec.host, sspec.port, sspec.protocol, sspec.appName,
            this, sspec.facilityName, sspec.enterpriseNumber, sspec.clientHostName);
    syslogAppenders.put(appenderName, syslogAppender);
    addAppender(syslogAppender);
  }
  return syslogAppenders;
}
 
开发者ID:nobeh,项目名称:log4j-configuration-builder,代码行数:18,代码来源:ConfigurationBuilder.java

示例3: createSyslogAppender

import org.apache.logging.log4j.core.appender.SyslogAppender; //导入依赖的package包/类
/**
 * Creates an instance of {@link SyslogAppender}. Parameters
 * match that of appearing in the same method in
 * {@link SyslogAppender}.
 * 
 * @param name
 * @param host
 * @param port
 * @param protocolStr
 * @param appName
 * @param config
 * @param facilityName
 * @param enterpriseNumber
 * @param clientHostName
 * @return an instance of {@link SyslogAppender}
 */
protected static SyslogAppender createSyslogAppender(String name, String host, int port,
    String protocolStr, String appName, Configuration config, String facilityName,
    int enterpriseNumber, String clientHostName) {
  final SslConfiguration sslConfig = null;
  int connectTimeoutMillis = 0;
  int reconnectionDelayMillis = 0;
  boolean immediateFail = true;
  boolean immediateFlush = true;
  boolean ignoreExceptions = true;
  Facility facility = Facility.toFacility(facilityName, Facility.USER);
  String id = null;
  boolean includeMdc = false;
  String mdcId = "mdc-ignored-id";
  String mdcPrefix = null;
  String eventPrefix = "|/" + clientHostName + "/" + appName + ".log|";
  boolean newLine = true;
  String escapeNL = null;
  String msgId = appName;
  String mdcExcludes = null;
  String mdcIncludes = null;
  String mdcRequired = null;
  String format = "RFC5424";
  Filter filter = null;
  Charset charsetName = Charset.defaultCharset();
  String exceptionPattern = null;
  LoggerFields[] loggerFields = new LoggerFields[0];
  boolean advertise = false;
  SyslogAppender sla = SyslogAppender.createAppender(host, port, protocolStr, sslConfig,
      connectTimeoutMillis, reconnectionDelayMillis, immediateFail, name, immediateFlush,
      ignoreExceptions, facility, id, enterpriseNumber, includeMdc, mdcId, mdcPrefix, eventPrefix,
      newLine, escapeNL, appName, msgId, mdcExcludes, mdcIncludes, mdcRequired, format, filter,
      config, charsetName, exceptionPattern, loggerFields, advertise);
  return sla;
}
 
开发者ID:nobeh,项目名称:log4j-configuration-builder,代码行数:51,代码来源:ConfigurationBuilder.java

示例4: initTargetAppender

import org.apache.logging.log4j.core.appender.SyslogAppender; //导入依赖的package包/类
@Override
public void initTargetAppender() {
    targetAppender = SyslogAppender.newSyslogAppenderBuilder()
            .withName(getTargetAppenderName())
            .withHost("localhost")
            .withPort(514)
            .withProtocol(Protocol.UDP)
            .withLayout(
                    PatternLayout.newBuilder().withPattern("%d{ISO8601} %-5level %logger - %msg%n").build())
            .setFacility(Facility.LOCAL1)
            .build();
}
 
开发者ID:apache,项目名称:syncope,代码行数:13,代码来源:SyslogRewriteAuditAppender.java


注:本文中的org.apache.logging.log4j.core.appender.SyslogAppender类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。