本文整理匯總了Java中org.apache.logging.log4j.core.config.Configuration.getAdvertiser方法的典型用法代碼示例。如果您正苦於以下問題:Java Configuration.getAdvertiser方法的具體用法?Java Configuration.getAdvertiser怎麽用?Java Configuration.getAdvertiser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.logging.log4j.core.config.Configuration
的用法示例。
在下文中一共展示了Configuration.getAdvertiser方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAppender
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
@PluginFactory
public static FileLogAppender createAppender(@PluginAttribute("fileName") String fileName, @PluginAttribute("filePattern") String filePattern, @PluginAttribute("append") String append, @PluginAttribute("name") String name, @PluginAttribute("immediateFlush") String immediateFlush, @PluginAttribute("bufferSize") String bufferSizeStr, @PluginElement("Policy") TriggeringPolicy policy, @PluginElement("Strategy") RolloverStrategy strategy, @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginElement("Filter") Filter filter, @PluginAttribute("ignoreExceptions") String ignore, @PluginAttribute("advertise") String advertise, @PluginAttribute("advertiseURI") String advertiseURI, @PluginConfiguration Configuration config) {
boolean isAppend = Booleans.parseBoolean(append, true);
boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
boolean isAdvertise = Boolean.parseBoolean(advertise);
int bufferSize = Integers.parseInt(bufferSizeStr, 262144);
if (name == null) {
LOGGER.error("No name provided for FileAppender");
return null;
} else if (fileName == null) {
LOGGER.error("No filename was provided for FileAppender with name " + name);
return null;
} else if (filePattern == null) {
LOGGER.error("No filename pattern provided for FileAppender with name " + name);
return null;
} else if (policy == null) {
LOGGER.error("A TriggeringPolicy must be provided");
return null;
} else {
if (strategy == null) {
strategy = DefaultRolloverStrategy.createStrategy(null, null, null, String.valueOf(-1), config);
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
RollingRandomAccessFileManager manager = RollingRandomAccessFileManager.getRollingRandomAccessFileManager(fileName, filePattern, isAppend, isFlush, bufferSize, policy, strategy, advertiseURI, layout);
return manager == null ? null : new FileLogAppender(name, layout, filter, manager, fileName, filePattern, ignoreExceptions, isFlush, bufferSize, isAdvertise ? config.getAdvertiser() : null);
}
}
示例2: build
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
@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);
}
示例3: createAppender
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
/**
* Create a RollingFileAppender.
* @param fileName The name of the file that is actively written to. (required).
* @param filePattern The pattern of the file name to use on rollover. (required).
* @param append If true, events are appended to the file. If false, the file
* is overwritten when opened. Defaults to "true"
* @param name The name of the Appender (required).
* @param bufferedIO When true, I/O will be buffered. Defaults to "true".
* @param immediateFlush When true, events are immediately flushed. Defaults to "true".
* @param policy The triggering policy. (required).
* @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
* @param layout The layout to use (defaults to the default PatternLayout).
* @param filter The Filter or null.
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
* they are propagated to the caller.
* @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
* @param advertiseURI The advertised URI which can be used to retrieve the file contents.
* @param config The Configuration.
* @return A RollingFileAppender.
*/
@PluginFactory
public static RollingFileAppender createAppender(
@PluginAttribute("fileName") final String fileName,
@PluginAttribute("filePattern") final String filePattern,
@PluginAttribute("append") final String append,
@PluginAttribute("name") final String name,
@PluginAttribute("bufferedIO") final String bufferedIO,
@PluginAttribute("immediateFlush") final String immediateFlush,
@PluginElement("Policy") final TriggeringPolicy policy,
@PluginElement("Strategy") RolloverStrategy strategy,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("ignoreExceptions") final String ignore,
@PluginAttribute("advertise") final String advertise,
@PluginAttribute("advertiseURI") final String advertiseURI,
@PluginConfiguration final Configuration config) {
final boolean isAppend = Booleans.parseBoolean(append, true);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
if (name == null) {
LOGGER.error("No name provided for FileAppender");
return null;
}
if (fileName == null) {
LOGGER.error("No filename was provided for FileAppender with name " + name);
return null;
}
if (filePattern == null) {
LOGGER.error("No filename pattern provided for FileAppender with name " + name);
return null;
}
if (policy == null) {
LOGGER.error("A TriggeringPolicy must be provided");
return null;
}
if (strategy == null) {
strategy = DefaultRolloverStrategy.createStrategy(null, null, null,
String.valueOf(Deflater.DEFAULT_COMPRESSION), config);
}
if (layout == null) {
layout = PatternLayout.createLayout(null, null, null, null, null);
}
final RollingFileManager manager = RollingFileManager.getFileManager(fileName, filePattern, isAppend,
isBuffered, policy, strategy, advertiseURI, layout);
if (manager == null) {
return null;
}
return new RollingFileAppender(name, layout, filter, manager, fileName, filePattern,
ignoreExceptions, isFlush, isAdvertise ? config.getAdvertiser() : null);
}
示例4: createAppender
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
/**
* Create a File Appender.
*
* @param fileName The name and path of the file.
* @param append "True" if the file should be appended to, "false" if it
* should be overwritten. The default is "true".
* @param name The name of the Appender.
* @param immediateFlush "true" if the contents should be flushed on every
* write, "false" otherwise. The default is "true".
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
* they are propagated to the caller.
* @param layout The layout to use to format the event. If no layout is
* provided the default PatternLayout will be used.
* @param filter The filter, if any, to use.
* @param advertise "true" if the appender configuration should be
* advertised, "false" otherwise.
* @param advertiseURI The advertised URI which can be used to retrieve the
* file contents.
* @param config The Configuration.
* @return The FileAppender.
*/
@PluginFactory
public static RandomAccessFileAppender createAppender(
@PluginAttribute("fileName") final String fileName,
@PluginAttribute("append") final String append,
@PluginAttribute("name") final String name,
@PluginAttribute("immediateFlush") final String immediateFlush,
@PluginAttribute("ignoreExceptions") final String ignore,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filters") final Filter filter,
@PluginAttribute("advertise") final String advertise,
@PluginAttribute("advertiseURI") final String advertiseURI,
@PluginConfiguration final Configuration config) {
final boolean isAppend = Booleans.parseBoolean(append, true);
final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
if (name == null) {
LOGGER.error("No name provided for FileAppender");
return null;
}
if (fileName == null) {
LOGGER.error("No filename provided for FileAppender with name "
+ name);
return null;
}
if (layout == null) {
layout = PatternLayout.createLayout(null, null, null, null, null);
}
final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(
fileName, isAppend, isFlush, advertiseURI, layout
);
if (manager == null) {
return null;
}
return new RandomAccessFileAppender(
name, layout, filter, manager, fileName, ignoreExceptions, isFlush,
isAdvertise ? config.getAdvertiser() : null
);
}
示例5: createAppender
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
/**
* Create a File Appender.
* @param fileName The name and path of the file.
* @param append "True" if the file should be appended to, "false" if it should be overwritten.
* The default is "true".
* @param locking "True" if the file should be locked. The default is "false".
* @param name The name of the Appender.
* @param immediateFlush "true" if the contents should be flushed on every write, "false" otherwise. The default
* is "true".
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
* they are propagated to the caller.
* @param bufferedIO "true" if I/O should be buffered, "false" otherwise. The default is "true".
* @param layout The layout to use to format the event. If no layout is provided the default PatternLayout
* will be used.
* @param filter The filter, if any, to use.
* @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
* @param advertiseURI The advertised URI which can be used to retrieve the file contents.
* @param config The Configuration
* @return The FileAppender.
*/
@PluginFactory
public static FileAppender createAppender(
@PluginAttribute("fileName") final String fileName,
@PluginAttribute("append") final String append,
@PluginAttribute("locking") final String locking,
@PluginAttribute("name") final String name,
@PluginAttribute("immediateFlush") final String immediateFlush,
@PluginAttribute("ignoreExceptions") final String ignore,
@PluginAttribute("bufferedIO") final String bufferedIO,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filters") final Filter filter,
@PluginAttribute("advertise") final String advertise,
@PluginAttribute("advertiseURI") final String advertiseURI,
@PluginConfiguration final Configuration config) {
final boolean isAppend = Booleans.parseBoolean(append, true);
final boolean isLocking = Boolean.parseBoolean(locking);
boolean isBuffered = Booleans.parseBoolean(bufferedIO, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
if (isLocking && isBuffered) {
if (bufferedIO != null) {
LOGGER.warn("Locking and buffering are mutually exclusive. No buffering will occur for " + fileName);
}
isBuffered = false;
}
final boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
if (name == null) {
LOGGER.error("No name provided for FileAppender");
return null;
}
if (fileName == null) {
LOGGER.error("No filename provided for FileAppender with name " + name);
return null;
}
if (layout == null) {
layout = PatternLayout.createLayout(null, null, null, null, null);
}
final FileManager manager = FileManager.getFileManager(fileName, isAppend, isLocking, isBuffered, advertiseURI,
layout);
if (manager == null) {
return null;
}
return new FileAppender(name, layout, filter, manager, fileName, ignoreExceptions, isFlush,
isAdvertise ? config.getAdvertiser() : null);
}
示例6: createAppender
import org.apache.logging.log4j.core.config.Configuration; //導入方法依賴的package包/類
/**
*
* @param host The name of the host to connect to.
* @param portNum The port to connect to on the target host.
* @param protocol The Protocol to use.
* @param delay The interval in which failed writes should be retried.
* @param immediateFail True if the write should fail if no socket is immediately available.
* @param name The name of the Appender.
* @param immediateFlush "true" if data should be flushed on each write.
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
* they are propagated to the caller.
* @param layout The layout to use (defaults to SerializedLayout).
* @param filter The Filter or null.
* @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
* @param config The Configuration
* @return A SocketAppender.
*/
@PluginFactory
public static SocketAppender createAppender(
@PluginAttribute("host") final String host,
@PluginAttribute("port") final String portNum,
@PluginAttribute("protocol") final String protocol,
@PluginAttribute("reconnectionDelay") final String delay,
@PluginAttribute("immediateFail") final String immediateFail,
@PluginAttribute("name") final String name,
@PluginAttribute("immediateFlush") final String immediateFlush,
@PluginAttribute("ignoreExceptions") final String ignore,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filters") final Filter filter,
@PluginAttribute("advertise") final String advertise,
@PluginConfiguration final Configuration config) {
boolean isFlush = Booleans.parseBoolean(immediateFlush, true);
final boolean isAdvertise = Boolean.parseBoolean(advertise);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final boolean fail = Booleans.parseBoolean(immediateFail, true);
final int reconnectDelay = AbstractAppender.parseInt(delay, 0);
final int port = AbstractAppender.parseInt(portNum, 0);
if (layout == null) {
layout = SerializedLayout.createLayout();
}
if (name == null) {
LOGGER.error("No name provided for SocketAppender");
return null;
}
final Protocol p = EnglishEnums.valueOf(Protocol.class, protocol != null ? protocol : Protocol.TCP.name());
if (p.equals(Protocol.UDP)) {
isFlush = true;
}
final AbstractSocketManager manager = createSocketManager(p, host, port, reconnectDelay, fail, layout);
if (manager == null) {
return null;
}
return new SocketAppender(name, layout, filter, manager, ignoreExceptions, isFlush,
isAdvertise ? config.getAdvertiser() : null);
}