本文整理了Java中org.apache.logging.log4j.core.config.plugins.Plugin.<init>()
方法的一些代码示例,展示了Plugin.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.<init>()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.config.plugins.Plugin
类名称:Plugin
方法名:<init>
暂无
代码示例来源:origin: apache/hive
/**
* A log filter that filters test messages coming from the logger.
*/
@Plugin(name = "TestFilter", category = "Core", elementType="filter", printObject = true)
private static class TestFilter extends AbstractFilter {
@Override
public Result filter(LogEvent event) {
if (event.getLevel().equals(Level.INFO) && "SessionState".equals(event.getLoggerName())) {
if (event.getMessage().getFormattedMessage().startsWith("PREHOOK:")
|| event.getMessage().getFormattedMessage().startsWith("POSTHOOK:")
|| event.getMessage().getFormattedMessage().startsWith("unix_timestamp(void)")
|| event.getMessage().getFormattedMessage().startsWith("Warning: ")
) {
return Result.ACCEPT;
}
}
return Result.DENY;
}
@PluginFactory
public static TestFilter createFilter() {
return new TestFilter();
}
}
代码示例来源:origin: apache/hive
/**
* A NullAppender merely exists, it never outputs a message to any device.
*/
@Plugin(name = "NullAppender", category = "Core", elementType = "appender", printObject = false)
public class NullAppender extends AbstractAppender {
private static LoggerContext context = (LoggerContext) LogManager.getContext(false);
private static Configuration configuration = context.getConfiguration();
protected NullAppender(String name, Filter filter,
Layout<? extends Serializable> layout, boolean ignoreExceptions) {
super(name, filter, layout, ignoreExceptions);
}
@PluginFactory
public static NullAppender createNullAppender() {
return new NullAppender("NullAppender", null, PatternLayout.createDefaultLayout(), true);
}
public void addToLogger(String loggerName, Level level) {
LoggerConfig loggerConfig = configuration.getLoggerConfig(loggerName);
loggerConfig.addAppender(this, level, null);
context.updateLoggers();
}
public void append(LogEvent event) {
// no-op
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
*
*/
@Plugin(name="ExtendedLevel", category=Level.CATEGORY)
public class ExtendedLevels {
public static final Level NOTE = Level.forName("NOTE", 350);
public static final Level DETAIL = Level.forName("DETAIL", 450);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "Nested", category = "Test")
public static class Nested {
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
*
*/
@Plugin(name = "TestRewritePolicy", category = Core.CATEGORY_NAME, elementType = "rewritePolicy", printObject = true)
public class TestRewritePolicy implements RewritePolicy {
@Override
public LogEvent rewrite(final LogEvent source) {
return new Log4jLogEvent.Builder(source).build();
}
@PluginFactory
public static TestRewritePolicy createPolicy() {
return new TestRewritePolicy();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
*
*/
@Plugin(name="AlwaysFail", category ="Core", elementType=Appender.ELEMENT_TYPE, printObject=true)
public class AlwaysFailAppender extends AbstractAppender {
private AlwaysFailAppender(final String name) {
super(name, null, null, false);
}
@Override
public void append(final LogEvent event) {
throw new LoggingException("Always fail");
}
@PluginFactory
public static AlwaysFailAppender createAppender(
@PluginAttribute("name") @Required(message = "A name for the Appender must be specified") final String name) {
return new AlwaysFailAppender(name);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "memory", category = Core.CATEGORY_NAME, elementType = "advertiser", printObject = false)
public class InMemoryAdvertiser implements Advertiser {
private static Map<Object, Map<String, String>> properties = new HashMap<>();
public static Map<Object, Map<String, String>> getAdvertisedEntries()
{
final Map<Object, Map<String, String>> result = new HashMap<>();
result.putAll(properties);
return result;
}
@Override
public Object advertise(final Map<String, String> newEntry) {
final Object object = new Object();
properties.put(object, new HashMap<>(newEntry));
return object;
}
@Override
public void unadvertise(final Object advertisedObject) {
properties.remove(advertisedObject);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "HostAndPort", category = "Test")
public class HostAndPort {
private final InetSocketAddress address;
private HostAndPort(final InetSocketAddress address) {
this.address = address;
}
public boolean isValid() {
return !address.isUnresolved();
}
@PluginFactory
public static HostAndPort createPlugin(
@ValidHost(message = "Unit test (host)") @PluginAttribute("host") final String host,
@ValidPort(message = "Unit test (port)") @PluginAttribute("port") final int port) {
return new HostAndPort(new InetSocketAddress(host, port));
}
@Override
public String toString() {
return "HostAndPort{" +
"address=" + address +
'}';
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
*
*/
@Plugin(name = "BasicLayout", category = Core.CATEGORY_NAME, elementType = "layout", printObject = true)
public class BasicLayout extends AbstractStringLayout {
private static final String HEADER = "Header" + Strings.LINE_SEPARATOR;
public BasicLayout(final Charset charset) {
super(charset);
}
@Override
public byte[] getHeader() {
return getBytes(HEADER);
}
@Override
public String toSerializable(final LogEvent event) {
return event.getMessage().getFormattedMessage() + Strings.LINE_SEPARATOR;
}
/**
*/
@PluginFactory
public static BasicLayout createLayout() {
return new BasicLayout(StandardCharsets.UTF_8);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name="FailOnce", category ="Core", elementType=Appender.ELEMENT_TYPE, printObject=true)
public class FailOnceAppender extends AbstractAppender {
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "UsesLoggingAppender", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true)
public final class UsesLoggingAppender extends AbstractAppender {
代码示例来源:origin: apache/hive
@Plugin(name = "CapturingLogAppender", category="Core", elementType="appender", printObject = true)
public class CapturingLogAppender extends AbstractAppender {
private static List<LogEvent> EVENTS = new ArrayList<>();
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name="Block", category ="Core", elementType=Appender.ELEMENT_TYPE, printObject=true)
public class BlockingAppender extends AbstractAppender {
public volatile boolean running = true;
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "Validator", category = "Test")
public class ValidatingPlugin {
代码示例来源:origin: apache/hive
@Plugin(name = "PidFilePatternConverter", category = "FileConverter")
@ConverterKeys({ "pid" })
public class PidFilePatternConverter extends AbstractPatternConverter implements
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "ValidatingPluginWithTypedBuilder", category = "Test")
public class ValidatingPluginWithTypedBuilder {
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "PluginWithGenericSubclassFoo1Builder", category = "Test")
public class PluginWithGenericSubclassFoo1Builder extends AbstractPluginWithGenericBuilder {
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
* Test plugin class for unit tests.
*/
@Plugin(name = "Fake", category = "Test")
@PluginAliases({"AnotherFake", "StillFake"})
public class FakePlugin {
@Plugin(name = "Nested", category = "Test")
public static class Nested {
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "TestFormatPatternConverter", category = "Converter")
@ConverterKeys("testformat")
public static final class TestFormatPatternConverter extends LogEventPatternConverter {
private TestFormatPatternConverter() {
super("Format", "testformat");
}
public static TestFormatPatternConverter newInstance(final String[] options) {
return new TestFormatPatternConverter();
}
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
toAppendTo.append(event.getMessage().getFormat());
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Plugin(name = "TestParametersPatternConverter", category = "Converter")
@ConverterKeys("testparameters")
public static final class TestParametersPatternConverter extends LogEventPatternConverter {
private TestParametersPatternConverter() {
super("Parameters", "testparameters");
}
public static TestParametersPatternConverter newInstance(final String[] options) {
return new TestParametersPatternConverter();
}
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
toAppendTo.append('[');
Object[] parameters = event.getMessage().getParameters();
if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
StringBuilders.appendValue(toAppendTo, parameters[i]);
if (i != parameters.length - 1) {
toAppendTo.append(',');
}
}
}
toAppendTo.append(']');
}
}
内容来源于网络,如有侵权,请联系作者删除!