/** * Gets an instance of the class. * * @param config The current Configuration. * @param options pattern options, an array of two elements: pattern, max length (defaults to 100 on invalid value). * @return instance of class. */ public static MaxLengthConverter newInstance(final Configuration config, final String[] options) { if (options.length != 2) { LOGGER.error("Incorrect number of options on maxLength: expected 2 received {}: {}", options.length, options); return null; } if (options[0] == null) { LOGGER.error("No pattern supplied on maxLength"); return null; } if (options[1] == null) { LOGGER.error("No length supplied on maxLength"); return null; } final PatternParser parser = PatternLayout.createPatternParser(config); final List<PatternFormatter> formatters = parser.parse(options[0]); return new MaxLengthConverter(formatters, AbstractAppender.parseInt(options[1], 100)); }
final int bufferSizeInt = AbstractAppender.parseInt(bufferSize, 0); final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
/** * Factory method for creating a JDBC appender within the plugin manager. * * @see Builder * @deprecated use {@link #newBuilder()} */ @Deprecated public static <B extends Builder<B>> JdbcAppender createAppender(final String name, final String ignore, final Filter filter, final ConnectionSource connectionSource, final String bufferSize, final String tableName, final ColumnConfig[] columnConfigs) { Assert.requireNonEmpty(name, "Name cannot be empty"); Objects.requireNonNull(connectionSource, "ConnectionSource cannot be null"); Assert.requireNonEmpty(tableName, "Table name cannot be empty"); Assert.requireNonEmpty(columnConfigs, "ColumnConfigs cannot be empty"); final int bufferSizeInt = AbstractAppender.parseInt(bufferSize, 0); final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true); return JdbcAppender.<B>newBuilder() .setBufferSize(bufferSizeInt) .setColumnConfigs(columnConfigs) .setConnectionSource(connectionSource) .setTableName(tableName) .withName(name) .withIgnoreExceptions(ignoreExceptions) .withFilter(filter) .build(); }
final int smtpPort = AbstractAppender.parseInt(smtpPortStr, 0); final boolean isSmtpDebug = Boolean.parseBoolean(smtpDebug); final int bufferSize = bufferSizeStr == null ? DEFAULT_BUFFER_SIZE : Integer.parseInt(bufferSizeStr);
/** * Builds a SocketAppender. * <ul> * <li>Removed deprecated "delayMillis", use "reconnectionDelayMillis".</li> * <li>Removed deprecated "reconnectionDelay", use "reconnectionDelayMillis".</li> * </ul> */ public static class Builder extends AbstractBuilder<Builder> implements org.apache.logging.log4j.core.util.Builder<SocketAppender> { @SuppressWarnings("resource") @Override public SocketAppender build() { boolean immediateFlush = isImmediateFlush(); final boolean bufferedIo = isBufferedIo(); final Layout<? extends Serializable> layout = getLayout(); if (layout == null) { AbstractLifeCycle.LOGGER.error("No layout provided for SocketAppender"); return null; } final String name = getName(); if (name == null) { AbstractLifeCycle.LOGGER.error("No name provided for SocketAppender"); return null; } final Protocol protocol = getProtocol(); final Protocol actualProtocol = protocol != null ? protocol : Protocol.TCP; if (actualProtocol == Protocol.UDP) {