Java 类org.apache.logging.log4j.core.net.Facility 实例源码

项目:log4j-configuration-builder    文件:ConfigurationBuilder.java   
/**
 * 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;
}
项目:syncope    文件:SyslogRewriteAuditAppender.java   
@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();
}
项目:log4j2    文件:RFC5424Layout.java   
/**
 * Create the RFC 5424 Layout.
 *
 * @param facility         The Facility is used to try to classify the message.
 * @param id               The default structured data id to use when formatting according to RFC 5424.
 * @param ein              The IANA enterprise number.
 * @param includeMDC       Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog
 *                         record. Defaults to "true:.
 * @param mdcId            The id to use for the MDC Structured Data Element.
 * @param mdcPrefix        The prefix to add to MDC key names.
 * @param eventPrefix      The prefix to add to event key names.
 * @param includeNL        If true, a newline will be appended to the end of the syslog record. The default is false.
 * @param escapeNL         String that should be used to replace newlines within the message text.
 * @param appName          The value to use as the APP-NAME in the RFC 5424 syslog record.
 * @param msgId            The default value to be used in the MSGID field of RFC 5424 syslog records.
 * @param excludes         A comma separated list of MDC keys that should be excluded from the LogEvent.
 * @param includes         A comma separated list of MDC keys that should be included in the FlumeEvent.
 * @param required         A comma separated list of MDC keys that must be present in the MDC.
 * @param exceptionPattern The pattern for formatting exceptions.
 * @param useTLSMessageFormat If true the message will be formatted according to RFC 5425.
 * @param loggerFields     Container for the KeyValuePairs containing the patterns
 * @param config           The Configuration. Some Converters require access to the Interpolator.
 * @return An RFC5424Layout.
 */
@PluginFactory
public static RFC5424Layout createLayout(
        @PluginAttribute("facility") final String facility,
        @PluginAttribute("id") final String id,
        @PluginAttribute("enterpriseNumber") final String ein,
        @PluginAttribute("includeMDC") final String includeMDC,
        @PluginAttribute("mdcId") String mdcId,
        @PluginAttribute("mdcPrefix") final String mdcPrefix,
        @PluginAttribute("eventPrefix") final String eventPrefix,
        @PluginAttribute("newLine") final String includeNL,
        @PluginAttribute("newLineEscape") final String escapeNL,
        @PluginAttribute("appName") final String appName,
        @PluginAttribute("messageId") final String msgId,
        @PluginAttribute("mdcExcludes") final String excludes,
        @PluginAttribute("mdcIncludes") String includes,
        @PluginAttribute("mdcRequired") final String required,
        @PluginAttribute("exceptionPattern") final String exceptionPattern,
        @PluginAttribute("useTLSMessageFormat") final String useTLSMessageFormat, // RFC 5425
        @PluginElement("LoggerFields") final LoggerFields[] loggerFields,
        @PluginConfiguration final Configuration config) {
    final Charset charset = Charsets.UTF_8;
    if (includes != null && excludes != null) {
        LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
        includes = null;
    }
    final Facility f = Facility.toFacility(facility, Facility.LOCAL0);
    final int enterpriseNumber = Integers.parseInt(ein, DEFAULT_ENTERPRISE_NUMBER);
    final boolean isMdc = Booleans.parseBoolean(includeMDC, true);
    final boolean includeNewLine = Boolean.parseBoolean(includeNL);
    final boolean useTlsMessageFormat = Booleans.parseBoolean(useTLSMessageFormat, false);
    if (mdcId == null) {
        mdcId = DEFAULT_MDCID;
    }

    return new RFC5424Layout(config, f, id, enterpriseNumber, isMdc, includeNewLine, escapeNL, mdcId, mdcPrefix,
            eventPrefix, appName, msgId, excludes, includes, required, charset, exceptionPattern,
            useTlsMessageFormat, loggerFields);
}
项目:log4j2    文件:SyslogLayout.java   
/**
 * Create a SyslogLayout.
 * @param facility The Facility is used to try to classify the message.
 * @param includeNL If true a newline will be appended to the result.
 * @param escapeNL Pattern to use for replacing newlines.
 * @param charsetName The character set.
 * @return A SyslogLayout.
 */
@PluginFactory
public static SyslogLayout createLayout(
        @PluginAttribute("facility") final String facility,
        @PluginAttribute("newLine") final String includeNL,
        @PluginAttribute("newLineEscape") final String escapeNL,
        @PluginAttribute("charset") final String charsetName) {
    final Charset charset = Charsets.getSupportedCharset(charsetName);
    final boolean includeNewLine = Boolean.parseBoolean(includeNL);
    final Facility f = Facility.toFacility(facility, Facility.LOCAL0);
    return new SyslogLayout(f, includeNewLine, escapeNL, charset);
}
项目:logging-log4j2    文件:Rfc5424Layout.java   
/**
 * Create the RFC 5424 Layout.
 *
 * @param facility The Facility is used to try to classify the message.
 * @param id The default structured data id to use when formatting according to RFC 5424.
 * @param enterpriseNumber The IANA enterprise number.
 * @param includeMDC Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog
 *            record. Defaults to "true:.
 * @param mdcId The id to use for the MDC Structured Data Element.
 * @param mdcPrefix The prefix to add to MDC key names.
 * @param eventPrefix The prefix to add to event key names.
 * @param newLine If true, a newline will be appended to the end of the syslog record. The default is false.
 * @param escapeNL String that should be used to replace newlines within the message text.
 * @param appName The value to use as the APP-NAME in the RFC 5424 syslog record.
 * @param msgId The default value to be used in the MSGID field of RFC 5424 syslog records.
 * @param excludes A comma separated list of MDC keys that should be excluded from the LogEvent.
 * @param includes A comma separated list of MDC keys that should be included in the FlumeEvent.
 * @param required A comma separated list of MDC keys that must be present in the MDC.
 * @param exceptionPattern The pattern for formatting exceptions.
 * @param useTlsMessageFormat If true the message will be formatted according to RFC 5425.
 * @param loggerFields Container for the KeyValuePairs containing the patterns
 * @param config The Configuration. Some Converters require access to the Interpolator.
 * @return An Rfc5424Layout.
 */
@PluginFactory
public static Rfc5424Layout createLayout(
        // @formatter:off
        @PluginAttribute(value = "facility", defaultString = "LOCAL0") final Facility facility,
        @PluginAttribute("id") final String id,
        @PluginAttribute(value = "enterpriseNumber", defaultInt = DEFAULT_ENTERPRISE_NUMBER)
        final int enterpriseNumber,
        @PluginAttribute(value = "includeMDC", defaultBoolean = true) final boolean includeMDC,
        @PluginAttribute(value = "mdcId", defaultString = DEFAULT_MDCID) final String mdcId,
        @PluginAttribute("mdcPrefix") final String mdcPrefix,
        @PluginAttribute("eventPrefix") final String eventPrefix,
        @PluginAttribute(value = "newLine") final boolean newLine,
        @PluginAttribute("newLineEscape") final String escapeNL,
        @PluginAttribute("appName") final String appName,
        @PluginAttribute("messageId") final String msgId,
        @PluginAttribute("mdcExcludes") final String excludes,
        @PluginAttribute("mdcIncludes") String includes,
        @PluginAttribute("mdcRequired") final String required,
        @PluginAttribute("exceptionPattern") final String exceptionPattern,
        // RFC 5425
        @PluginAttribute(value = "useTlsMessageFormat") final boolean useTlsMessageFormat,
        @PluginElement("LoggerFields") final LoggerFields[] loggerFields,
        @PluginConfiguration final Configuration config) {
    // @formatter:on
    if (includes != null && excludes != null) {
        LOGGER.error("mdcIncludes and mdcExcludes are mutually exclusive. Includes wil be ignored");
        includes = null;
    }

    return new Rfc5424Layout(config, facility, id, enterpriseNumber, includeMDC, newLine, escapeNL, mdcId,
            mdcPrefix, eventPrefix, appName, msgId, excludes, includes, required, StandardCharsets.UTF_8,
            exceptionPattern, useTlsMessageFormat, loggerFields);
}
项目:logging-log4j2    文件:TlsSyslogAppenderTest.java   
private SyslogAppender createAppender() {
    String format;

    if (messageFormat == TlsSyslogMessageFormat.LEGACY_BSD) {
        format = "LEGACY_BSD";
    } else {
        format = "RFC5424";
    }

    return SyslogAppender.createAppender("localhost", PORTNUM, "SSL", sslConfiguration, 0, -1, true, "Test", true,
        false, Facility.LOCAL0, "Audit", 18060, true, "RequestContext", null, null, includeNewLine, null,
        "TestApp", "Test", null, "ipAddress,loginId", null, format, null, null, null, null, null, false);
}
项目:log4j2    文件:SyslogLayout.java   
protected SyslogLayout(final Facility facility, final boolean includeNL, final String escapeNL, final Charset charset) {
    super(charset);
    this.facility = facility;
    this.includeNewLine = includeNL;
    this.escapeNewLine = escapeNL == null ? null : Matcher.quoteReplacement(escapeNL);
}
项目:logging-log4j2    文件:SyslogAppender.java   
public Facility getFacility() {
    return facility;
}
项目:logging-log4j2    文件:SyslogAppender.java   
public B setFacility(final Facility facility) {
    this.facility = facility;
    return asBuilder();
}
项目:logging-log4j2    文件:Rfc5424Layout.java   
public Facility getFacility() {
    return facility;
}
项目:logging-log4j2    文件:SyslogLayout.java   
public Facility getFacility() {
    return facility;
}
项目:logging-log4j2    文件:SyslogLayout.java   
public B setFacility(final Facility facility) {
    this.facility = facility;
    return asBuilder();
}
项目:logging-log4j2    文件:SyslogLayout.java   
protected SyslogLayout(final Facility facility, final boolean includeNL, final String escapeNL, final Charset charset) {
    super(charset);
    this.facility = facility;
    this.includeNewLine = includeNL;
    this.escapeNewLine = escapeNL == null ? null : Matcher.quoteReplacement(escapeNL);
}
项目:logging-log4j2    文件:SyslogAppenderTestBase.java   
protected Facility getExpectedFacility() {
    return Facility.LOCAL0;
}
项目:logging-log4j2    文件:SyslogAppenderCustomLayoutTest.java   
@Override
protected Facility getExpectedFacility() {
    return Facility.LOCAL3;
}
项目:logging-log4j2    文件:SyslogAppenderCustomLayoutTest.java   
@Override
protected Builder newSyslogAppenderBuilder(final String protocol, final String format, final boolean newLine) {
    final Builder builder = super.newSyslogAppenderBuilder(protocol, format, newLine);
    builder.withLayout(SyslogLayout.newBuilder().setFacility(Facility.LOCAL3).setIncludeNewLine(true).build());
    return builder;
}
项目:logging-log4j2    文件:SyslogLayout.java   
/**
 * Creates a SyslogLayout.
 * 
 * @param facility The Facility is used to try to classify the message.
 * @param includeNewLine If true a newline will be appended to the result.
 * @param escapeNL Pattern to use for replacing newlines.
 * @param charset The character set.
 * @return A SyslogLayout.
 * @deprecated Use {@link #newBuilder()}.
 */
@Deprecated
public static SyslogLayout createLayout(final Facility facility, final boolean includeNewLine,
                                        final String escapeNL, final Charset charset) {
    return new SyslogLayout(facility, includeNewLine, escapeNL, charset);
}
项目:logging-log4j2    文件:SyslogLayout.java   
/**
 * Gets the facility.
 * 
 * @return the facility
 */
public Facility getFacility() {
    return facility;
}