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


Java Protocol.SSL属性代码示例

本文整理汇总了Java中org.apache.logging.log4j.core.net.Protocol.SSL属性的典型用法代码示例。如果您正苦于以下问题:Java Protocol.SSL属性的具体用法?Java Protocol.SSL怎么用?Java Protocol.SSL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.logging.log4j.core.net.Protocol的用法示例。


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

示例1: createSocketManager

/**
 * Creates an AbstractSocketManager for TCP, UDP, and SSL.
 *
 * @throws IllegalArgumentException
 *             if the protocol cannot be handled.
 */
protected static AbstractSocketManager createSocketManager(final String name, Protocol protocol, final String host,
        final int port, final int connectTimeoutMillis, final SslConfiguration sslConfig,
        final int reconnectDelayMillis, final boolean immediateFail, final Layout<? extends Serializable> layout,
        final int bufferSize, final SocketOptions socketOptions) {
    if (protocol == Protocol.TCP && sslConfig != null) {
        // Upgrade TCP to SSL if an SSL config is specified.
        protocol = Protocol.SSL;
    }
    if (protocol != Protocol.SSL && sslConfig != null) {
        LOGGER.info("Appender {} ignoring SSL configuration for {} protocol", name, protocol);
    }
    switch (protocol) {
    case TCP:
        return TcpSocketManager.getSocketManager(host, port, connectTimeoutMillis, reconnectDelayMillis,
                immediateFail, layout, bufferSize, socketOptions);
    case UDP:
        return DatagramSocketManager.getSocketManager(host, port, layout, bufferSize);
    case SSL:
        return SslSocketManager.getSocketManager(sslConfig, host, port, connectTimeoutMillis, reconnectDelayMillis,
                immediateFail, layout, bufferSize, socketOptions);
    default:
        throw new IllegalArgumentException(protocol.toString());
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:30,代码来源:SocketAppender.java

示例2: build

@SuppressWarnings({"resource", "unchecked"})
@Override
public SyslogAppender build() {
    final Protocol protocol = getProtocol();
    final SslConfiguration sslConfiguration = getSslConfiguration();
    final boolean useTlsMessageFormat = sslConfiguration != null || protocol == Protocol.SSL;
    final Configuration configuration = getConfiguration();
    Layout<? extends Serializable> layout = getLayout();
    if (layout == null) {
        layout = RFC5424.equalsIgnoreCase(format)
                ? Rfc5424Layout.createLayout(facility, id, enterpriseNumber, includeMdc, mdcId, mdcPrefix,
                        eventPrefix, newLine, escapeNL, appName, msgId, excludes, includes, required,
                        exceptionPattern, useTlsMessageFormat, loggerFields, configuration)
                :
                // @formatter:off
                SyslogLayout.newBuilder()
                    .setFacility(facility)
                    .setIncludeNewLine(newLine)
                    .setEscapeNL(escapeNL)
                    .setCharset(charsetName)
                    .build();
                // @formatter:off
    }
    final String name = getName();
    if (name == null) {
        LOGGER.error("No name provided for SyslogAppender");
        return null;
    }
    final AbstractSocketManager manager = createSocketManager(name, protocol, getHost(), getPort(), getConnectTimeoutMillis(),
            sslConfiguration, getReconnectDelayMillis(), getImmediateFail(), layout, Constants.ENCODER_BYTE_BUFFER_SIZE, null);

    return new SyslogAppender(name, layout, getFilter(), isIgnoreExceptions(), isImmediateFlush(), manager,
            getAdvertise() ? configuration.getAdvertiser() : null);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:34,代码来源:SyslogAppender.java


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