"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

AsyncAppender.java  (apache-log4j-2.11.1-src):AsyncAppender.java  (apache-log4j-2.11.2-src)
skipping to change at line 44 skipping to change at line 44
import org.apache.logging.log4j.core.async.AsyncQueueFullPolicy; import org.apache.logging.log4j.core.async.AsyncQueueFullPolicy;
import org.apache.logging.log4j.core.async.AsyncQueueFullPolicyFactory; import org.apache.logging.log4j.core.async.AsyncQueueFullPolicyFactory;
import org.apache.logging.log4j.core.async.BlockingQueueFactory; import org.apache.logging.log4j.core.async.BlockingQueueFactory;
import org.apache.logging.log4j.core.async.DiscardingAsyncQueueFullPolicy; import org.apache.logging.log4j.core.async.DiscardingAsyncQueueFullPolicy;
import org.apache.logging.log4j.core.async.EventRoute; import org.apache.logging.log4j.core.async.EventRoute;
import org.apache.logging.log4j.core.async.InternalAsyncUtil; import org.apache.logging.log4j.core.async.InternalAsyncUtil;
import org.apache.logging.log4j.core.config.AppenderControl; import org.apache.logging.log4j.core.config.AppenderControl;
import org.apache.logging.log4j.core.config.AppenderRef; import org.apache.logging.log4j.core.config.AppenderRef;
import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationException; import org.apache.logging.log4j.core.config.ConfigurationException;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAliases; import org.apache.logging.log4j.core.config.plugins.PluginAliases;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red; import org.apache.logging.log4j.core.config.plugins.validation.constraints.Requi red;
import org.apache.logging.log4j.core.filter.AbstractFilterable;
import org.apache.logging.log4j.core.impl.Log4jLogEvent; import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.util.Log4jThread; import org.apache.logging.log4j.core.util.Log4jThread;
import org.apache.logging.log4j.spi.AbstractLogger; import org.apache.logging.log4j.spi.AbstractLogger;
/** /**
* Appends to one or more Appenders asynchronously. You can configure an AsyncAp pender with one or more Appenders and an * Appends to one or more Appenders asynchronously. You can configure an AsyncAp pender with one or more Appenders and an
* Appender to append to if the queue is full. The AsyncAppender does not allow a filter to be specified on the Appender * Appender to append to if the queue is full. The AsyncAppender does not allow a filter to be specified on the Appender
* references. * references.
*/ */
@Plugin(name = "Async", category = Core.CATEGORY_NAME, elementType = Appender.EL EMENT_TYPE, printObject = true) @Plugin(name = "Async", category = Core.CATEGORY_NAME, elementType = Appender.EL EMENT_TYPE, printObject = true)
public final class AsyncAppender extends AbstractAppender { public final class AsyncAppender extends AbstractAppender {
private static final int DEFAULT_QUEUE_SIZE = 1024; private static final int DEFAULT_QUEUE_SIZE = 1024;
private static final LogEvent SHUTDOWN_LOG_EVENT = new AbstractLogEvent() { private static final LogEvent SHUTDOWN_LOG_EVENT = new AbstractLogEvent() {
private static final long serialVersionUID = -1761035149477086330L;
}; };
private static final AtomicLong THREAD_SEQUENCE = new AtomicLong(1); private static final AtomicLong THREAD_SEQUENCE = new AtomicLong(1);
private final BlockingQueue<LogEvent> queue; private final BlockingQueue<LogEvent> queue;
private final int queueSize; private final int queueSize;
private final boolean blocking; private final boolean blocking;
private final long shutdownTimeout; private final long shutdownTimeout;
private final Configuration config; private final Configuration config;
private final AppenderRef[] appenderRefs; private final AppenderRef[] appenderRefs;
private final String errorRef; private final String errorRef;
private final boolean includeLocation; private final boolean includeLocation;
private AppenderControl errorAppender; private AppenderControl errorAppender;
private AsyncThread thread; private AsyncThread thread;
private AsyncQueueFullPolicy asyncQueueFullPolicy; private AsyncQueueFullPolicy asyncQueueFullPolicy;
private AsyncAppender(final String name, final Filter filter, final Appender Ref[] appenderRefs, private AsyncAppender(final String name, final Filter filter, final Appender Ref[] appenderRefs,
final String errorRef, final int queueSize, final bool final String errorRef, final int queueSize, final boolean blocking,
ean blocking, final boolean ignoreExceptions,
final boolean ignoreExceptions, final long shutdownTim final long shutdownTimeout, final Configuration config, final boolea
eout, final Configuration config, n includeLocation,
final boolean includeLocation, final BlockingQueueFact final BlockingQueueFactory<LogEvent> blockingQueueFactory, final Pro
ory<LogEvent> blockingQueueFactory) { perty[] properties) {
super(name, filter, null, ignoreExceptions); super(name, filter, null, ignoreExceptions, properties);
this.queue = blockingQueueFactory.create(queueSize); this.queue = blockingQueueFactory.create(queueSize);
this.queueSize = queueSize; this.queueSize = queueSize;
this.blocking = blocking; this.blocking = blocking;
this.shutdownTimeout = shutdownTimeout; this.shutdownTimeout = shutdownTimeout;
this.config = config; this.config = config;
this.appenderRefs = appenderRefs; this.appenderRefs = appenderRefs;
this.errorRef = errorRef; this.errorRef = errorRef;
this.includeLocation = includeLocation; this.includeLocation = includeLocation;
} }
skipping to change at line 273 skipping to change at line 276
final Configuration config, final boolean ignoreExceptions) { final Configuration config, final boolean ignoreExceptions) {
if (name == null) { if (name == null) {
LOGGER.error("No name provided for AsyncAppender"); LOGGER.error("No name provided for AsyncAppender");
return null; return null;
} }
if (appenderRefs == null) { if (appenderRefs == null) {
LOGGER.error("No appender references provided to AsyncAppender {}", name); LOGGER.error("No appender references provided to AsyncAppender {}", name);
} }
return new AsyncAppender(name, filter, appenderRefs, errorRef, size, blo cking, ignoreExceptions, return new AsyncAppender(name, filter, appenderRefs, errorRef, size, blo cking, ignoreExceptions,
shutdownTimeout, config, includeLocation, new ArrayBlockingQueueFact ory<LogEvent>()); shutdownTimeout, config, includeLocation, new ArrayBlockingQueueFact ory<LogEvent>(), null);
} }
@PluginBuilderFactory @PluginBuilderFactory
public static Builder newBuilder() { public static Builder newBuilder() {
return new Builder(); return new Builder();
} }
public static class Builder implements org.apache.logging.log4j.core.util.Bu public static class Builder<B extends Builder<B>> extends AbstractFilterable
ilder<AsyncAppender> { .Builder<B>
implements org.apache.logging.log4j.core.util.Builder<AsyncAppender>
{
@PluginElement("AppenderRef") @PluginElement("AppenderRef")
@Required(message = "No appender references provided to AsyncAppender") @Required(message = "No appender references provided to AsyncAppender")
private AppenderRef[] appenderRefs; private AppenderRef[] appenderRefs;
@PluginBuilderAttribute @PluginBuilderAttribute
@PluginAliases("error-ref") @PluginAliases("error-ref")
private String errorRef; private String errorRef;
@PluginBuilderAttribute @PluginBuilderAttribute
skipping to change at line 307 skipping to change at line 311
@PluginBuilderAttribute @PluginBuilderAttribute
private int bufferSize = DEFAULT_QUEUE_SIZE; private int bufferSize = DEFAULT_QUEUE_SIZE;
@PluginBuilderAttribute @PluginBuilderAttribute
@Required(message = "No name provided for AsyncAppender") @Required(message = "No name provided for AsyncAppender")
private String name; private String name;
@PluginBuilderAttribute @PluginBuilderAttribute
private boolean includeLocation = false; private boolean includeLocation = false;
@PluginElement("Filter")
private Filter filter;
@PluginConfiguration @PluginConfiguration
private Configuration configuration; private Configuration configuration;
@PluginBuilderAttribute @PluginBuilderAttribute
private boolean ignoreExceptions = true; private boolean ignoreExceptions = true;
@PluginElement(BlockingQueueFactory.ELEMENT_TYPE) @PluginElement(BlockingQueueFactory.ELEMENT_TYPE)
private BlockingQueueFactory<LogEvent> blockingQueueFactory = new ArrayB lockingQueueFactory<>(); private BlockingQueueFactory<LogEvent> blockingQueueFactory = new ArrayB lockingQueueFactory<>();
public Builder setAppenderRefs(final AppenderRef[] appenderRefs) { public Builder setAppenderRefs(final AppenderRef[] appenderRefs) {
skipping to change at line 354 skipping to change at line 355
public Builder setName(final String name) { public Builder setName(final String name) {
this.name = name; this.name = name;
return this; return this;
} }
public Builder setIncludeLocation(final boolean includeLocation) { public Builder setIncludeLocation(final boolean includeLocation) {
this.includeLocation = includeLocation; this.includeLocation = includeLocation;
return this; return this;
} }
public Builder setFilter(final Filter filter) {
this.filter = filter;
return this;
}
public Builder setConfiguration(final Configuration configuration) { public Builder setConfiguration(final Configuration configuration) {
this.configuration = configuration; this.configuration = configuration;
return this; return this;
} }
public Builder setIgnoreExceptions(final boolean ignoreExceptions) { public Builder setIgnoreExceptions(final boolean ignoreExceptions) {
this.ignoreExceptions = ignoreExceptions; this.ignoreExceptions = ignoreExceptions;
return this; return this;
} }
public Builder setBlockingQueueFactory(final BlockingQueueFactory<LogEve nt> blockingQueueFactory) { public Builder setBlockingQueueFactory(final BlockingQueueFactory<LogEve nt> blockingQueueFactory) {
this.blockingQueueFactory = blockingQueueFactory; this.blockingQueueFactory = blockingQueueFactory;
return this; return this;
} }
@Override @Override
public AsyncAppender build() { public AsyncAppender build() {
return new AsyncAppender(name, filter, appenderRefs, errorRef, buffe return new AsyncAppender(name, getFilter(), appenderRefs, errorRef,
rSize, blocking, ignoreExceptions, bufferSize, blocking, ignoreExceptions,
shutdownTimeout, configuration, includeLocation, blockingQueueFa shutdownTimeout, configuration, includeLocation, blockingQueueFa
ctory); ctory, getPropertyArray());
} }
} }
/** /**
* Thread that calls the Appenders. * Thread that calls the Appenders.
*/ */
private class AsyncThread extends Log4jThread { private class AsyncThread extends Log4jThread {
private volatile boolean shutdown = false; private volatile boolean shutdown = false;
private final List<AppenderControl> appenders; private final List<AppenderControl> appenders;
 End of changes. 9 change blocks. 
22 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)