Skip to content

Raise default async discard threshold to ERROR #3880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testCreateDiscardingRouterDefaultThresholdLevelInfo() {
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
assertEquals(
Level.INFO,
Level.ERROR,
((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).getThresholdLevel());
}

Expand All @@ -85,7 +85,7 @@ void testCreateDiscardingRouterCaseInsensitive() {
AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
toRootLowerCase(AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER));
assertEquals(
Level.INFO,
Level.ERROR,
((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).getThresholdLevel());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
* Property {@code "log4j2.AsyncQueueFullPolicy"} controls the routing behaviour. If this property is not specified or has
* value {@code "Default"}, this factory creates {@link DefaultAsyncQueueFullPolicy} objects.
* </p> <p>
* If this property has value {@code "Discard"}, this factory creates {@link DiscardingAsyncQueueFullPolicy} objects.
* By default, this router discards events of level {@code INFO}, {@code DEBUG} and {@code TRACE} if the queue is full.
* This can be adjusted with property {@code "log4j2.DiscardThreshold"} (name of the level at which to start
* discarding).
* If this property has value {@code "Discard"}, this factory creates {@link DiscardingAsyncQueueFullPolicy} objects. By
* default, this router discards events of level {@code ERROR}, {@code WARN}, {@code INFO}, {@code DEBUG} and {@code
* TRACE} if the queue is full. This can be adjusted with property {@code "log4j2.DiscardThreshold"} (name of the level
* at which to start discarding).
* </p> <p>
* For any other value, this
* factory interprets the value as the fully qualified name of a class implementing the {@link AsyncQueueFullPolicy}
Expand Down Expand Up @@ -104,8 +104,8 @@ private static AsyncQueueFullPolicy createCustomRouter(final String router) {

private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy() {
final PropertiesUtil util = PropertiesUtil.getProperties();
final String level = util.getStringProperty(PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL, Level.INFO.name());
final Level thresholdLevel = Level.toLevel(level, Level.INFO);
final String level = util.getStringProperty(PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL, Level.ERROR.name());
final Level thresholdLevel = Level.toLevel(level, Level.ERROR);
LOGGER.debug("Creating custom DiscardingAsyncQueueFullPolicy(discardThreshold:{})", thresholdLevel);
return new DiscardingAsyncQueueFullPolicy(thresholdLevel);
}
Expand Down
12 changes: 12 additions & 0 deletions src/changelog/.2.x.x/3880-default-discard-threshold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="https://logging.apache.org/xml/ns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
https://logging.apache.org/xml/ns
https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
type="fixed">
<issue id="3880" link="https://github.com/apache/logging-log4j2/pull/3880"/>
<description format="asciidoc">
Raise the async logger's default discard threshold to ERROR. This is intended to improve application resilience in the event of a full or failing disk.
</description>
</entry>
Loading