Java Code Examples for org.apache.logging.log4j.core.config.Property#EMPTY_ARRAY

The following examples show how to use org.apache.logging.log4j.core.config.Property#EMPTY_ARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpectatorAppender.java    From spectator with Apache License 2.0 6 votes vote down vote up
/** Create a new instance of the appender using the global spectator registry. */
@PluginFactory
public static SpectatorAppender createAppender(
    @PluginAttribute("name") String name,
    @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
    @PluginElement("Layout") Layout<? extends Serializable> layout,
    @PluginElement("Filters") Filter filter) {

  if (name == null) {
    LOGGER.error("no name provided for SpectatorAppender");
    return null;
  }

  return new SpectatorAppender(
      Spectator.globalRegistry(),
      name, filter, layout, ignoreExceptions,
      Property.EMPTY_ARRAY);
}
 
Example 2
Source File: MCRWebCLIContainer.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
ProcessCallable(MCRSession session, Session webSocketSession, ReentrantLock lock) {
    this.commands = new ArrayList<>();
    this.session = session;
    this.lock = lock;
    this.stopLogs = false;
    this.webSocketSession = webSocketSession;
    this.logGrabber = new Log4JGrabber(MCRWebCLIContainer.class.getSimpleName() + session.getID(), null,
        PatternLayout.createDefaultLayout(), true, Property.EMPTY_ARRAY);
    this.logGrabber.start();
    startLogging(true);
    cmdListPublisher = new SubmissionPublisher<>(ForkJoinPool.commonPool(), 1);
    this.currentCommand = "";
    this.continueIfOneFails = false;
    startSendingCommandQueue();
}
 
Example 3
Source File: SpectatorAppender.java    From spectator with Apache License 2.0 5 votes vote down vote up
/**
 * Add the spectator appender to the root logger. This method is intended to be called once
 * as part of the applications initialization process.
 *
 * @param registry
 *     Spectator registry to use for the appender.
 * @param name
 *     Name for the appender.
 * @param ignoreExceptions
 *     If set to true then the stack trace metrics are disabled.
 */
public static void addToRootLogger(
    Registry registry,
    String name,
    boolean ignoreExceptions) {
  final Appender appender = new SpectatorAppender(
      registry, name, null, null, ignoreExceptions, Property.EMPTY_ARRAY);
  appender.start();

  LoggerContext context = (LoggerContext) LogManager.getContext(false);
  Configuration config = context.getConfiguration();

  addToRootLogger(appender);
  config.addListener(reconfigurable -> addToRootLogger(appender));
}
 
Example 4
Source File: SpectatorAppenderTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void before() {
  registry = new DefaultRegistry();
  appender = new SpectatorAppender(
      registry, "foo", null, null, false, Property.EMPTY_ARRAY);
  appender.start();
}
 
Example 5
Source File: ListAppender.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
public ListAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout,
        final boolean newline, final boolean raw) {
    super(name, filter, layout, true, Property.EMPTY_ARRAY);
    this.newLine = newline;
    this.raw = raw;
    if (layout != null) {
        final byte[] bytes = layout.getHeader();
        if (bytes != null) {
            write(bytes);
        }
    }
}
 
Example 6
Source File: MemoryAppender.java    From syncope with Apache License 2.0 5 votes vote down vote up
protected MemoryAppender(
        final String name,
        final int size,
        final Filter filter,
        final boolean ignoreExceptions) {

    super(name, filter, null, ignoreExceptions, Property.EMPTY_ARRAY);
    this.statements = new CircularFifoQueue<>(size);
}
 
Example 7
Source File: SmtpAppender.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create a SmtpAppender.
 * @deprecated Use {@link #newBuilder()} to create and configure a {@link Builder} instance.
 * @see Builder
 */
public static SmtpAppender createAppender(final Configuration config, final String name, final String to,
                                          final String cc, final String bcc, final String from,
                                          final String replyTo, final String subject, final String smtpProtocol,
                                          final String smtpHost, final String smtpPortStr,
                                          final String smtpUsername, final String smtpPassword,
                                          final String smtpDebug, final String bufferSizeStr,
                                          Layout<? extends Serializable> layout, Filter filter,
                                          final String ignore) {
    if (name == null) {
        LOGGER.error("No name provided for SmtpAppender");
        return null;
    }

    final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
    final int smtpPort = AbstractAppender.parseInt(smtpPortStr, 0);
    final boolean isSmtpDebug = Boolean.parseBoolean(smtpDebug);
    final int bufferSize = bufferSizeStr == null ? DEFAULT_BUFFER_SIZE : Integer.parseInt(bufferSizeStr);

    if (layout == null) {
        layout = HtmlLayout.createDefaultLayout();
    }
    if (filter == null) {
        filter = ThresholdFilter.createFilter(null, null, null);
    }
    final Configuration configuration = config != null ? config : new DefaultConfiguration();

    final SmtpManager manager = SmtpManager.getSmtpManager(configuration, to, cc, bcc, from, replyTo, subject, smtpProtocol,
        smtpHost, smtpPort, smtpUsername, smtpPassword, isSmtpDebug, filter.toString(),  bufferSize, null);
    if (manager == null) {
        return null;
    }

    return new SmtpAppender(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY, manager);
}
 
Example 8
Source File: CountingNoOpAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public CountingNoOpAppender(final String name, final Layout<?> layout) {
    super(name, null, layout, true, Property.EMPTY_ARRAY);
}
 
Example 9
Source File: HangingAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public HangingAppender(final String name, final long delay, final long startupDelay, final long shutdownDelay) {
    super(name, null, null, true, Property.EMPTY_ARRAY);
    this.delay = delay;
    this.startupDelay = startupDelay;
    this.shutdownDelay = shutdownDelay;
}
 
Example 10
Source File: AbstractFilterable.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
protected AbstractFilterable(final Filter filter, Property[] propertyArray) {
    this.filter = filter;
    this.propertyArray = propertyArray == null ? Property.EMPTY_ARRAY : propertyArray;
}
 
Example 11
Source File: AbstractDatabaseAppenderTest.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public LocalAbstractDatabaseAppender(final String name, final Filter filter, final boolean ignoreExceptions,
                                     final LocalAbstractDatabaseManager manager) {
    super(name, filter, null, ignoreExceptions, Property.EMPTY_ARRAY, manager);
}
 
Example 12
Source File: LoggerTest.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
CountingAppender() {
    super("Counter", null, null, true, Property.EMPTY_ARRAY);
    counter = 0;
}
 
Example 13
Source File: DemoAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public DemoAppender(final Layout<?> layout) {
    super("demo", null, layout, true, Property.EMPTY_ARRAY);
}
 
Example 14
Source File: DemoAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public DemoAppender(final Layout<?> layout) {
    super("demo", null, layout, true, Property.EMPTY_ARRAY);
}
 
Example 15
Source File: ScriptAppenderSelector.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
private ScriptAppenderSelector(final String name, final Filter filter, final Layout<? extends Serializable> layout) {
    super(name, filter, layout, true, Property.EMPTY_ARRAY);
}
 
Example 16
Source File: NullAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
private NullAppender(final String name) {
    super(name, null, null, true, Property.EMPTY_ARRAY);
    // Do nothing
}
 
Example 17
Source File: StringPropertyAppender.java    From TweetwallFX with MIT License 4 votes vote down vote up
public StringPropertyAppender() {
    super(StringPropertyAppender.class.getName(), null, null, true, Property.EMPTY_ARRAY);
}
 
Example 18
Source File: TextAreaAppender.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
protected TextAreaAppender(String name, Filter filter,
                           org.apache.logging.log4j.core.Layout<? extends Serializable> layout, final boolean ignoreExceptions) {
  super(name, filter, layout, ignoreExceptions, Property.EMPTY_ARRAY);
}
 
Example 19
Source File: ListAppender.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
public ListAppender(final String name) {
    super(name, null, null, true, Property.EMPTY_ARRAY);
    newLine = false;
    raw = false;
}
 
Example 20
Source File: RewriteAppender.java    From logging-log4j2 with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a RewriteAppender.
 * @param name The name of the Appender.
 * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
 *               they are propagated to the caller.
 * @param appenderRefs An array of Appender names to call.
 * @param config The Configuration.
 * @param rewritePolicy The policy to use to modify the event.
 * @param filter A Filter to filter events.
 * @return The created RewriteAppender.
 */
@PluginFactory
public static RewriteAppender createAppender(
        @PluginAttribute @Required(message = "No name provided for RewriteAppender") final String name,
        @PluginAttribute(defaultBoolean = true) final boolean ignoreExceptions,
        @PluginElement @Required(message = "No appender references defined for RewriteAppender") final AppenderRef[] appenderRefs,
        @PluginConfiguration final Configuration config,
        @PluginElement final RewritePolicy rewritePolicy,
        @PluginElement final Filter filter) {
    return new RewriteAppender(name, filter, ignoreExceptions, appenderRefs, rewritePolicy, config, Property.EMPTY_ARRAY);
}