Skip to content

Commit b338d07

Browse files
committed
Remove DefaultLogEventFactory (#2163)
1 parent 0d6876d commit b338d07

File tree

5 files changed

+19
-132
lines changed

5 files changed

+19
-132
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
3333
import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
3434
import org.apache.logging.log4j.core.filter.AbstractFilterable;
35-
import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
3635
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
3736
import org.apache.logging.log4j.core.impl.LogEventFactory;
37+
import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
3838
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
3939
import org.apache.logging.log4j.message.Message;
4040
import org.apache.logging.log4j.plugins.Configurable;
@@ -44,6 +44,7 @@
4444
import org.apache.logging.log4j.plugins.PluginBuilderAttribute;
4545
import org.apache.logging.log4j.plugins.PluginElement;
4646
import org.apache.logging.log4j.plugins.PluginFactory;
47+
import org.apache.logging.log4j.plugins.di.DI;
4748
import org.apache.logging.log4j.plugins.validation.constraints.Required;
4849
import org.apache.logging.log4j.util.PerformanceSensitive;
4950
import org.apache.logging.log4j.util.StackLocatorUtil;
@@ -218,7 +219,7 @@ public B asBuilder() {
218219
* Default constructor.
219220
*/
220221
public LoggerConfig() {
221-
this.logEventFactory = DefaultLogEventFactory.newInstance();
222+
this.logEventFactory = DI.createInitializedFactory().getInstance(ReusableLogEventFactory.class);
222223
this.level = Level.ERROR;
223224
this.name = Strings.EMPTY;
224225
this.properties = null;
@@ -235,7 +236,7 @@ public LoggerConfig() {
235236
* @param additive true if the Logger is additive, false otherwise.
236237
*/
237238
public LoggerConfig(final String name, final Level level, final boolean additive) {
238-
this.logEventFactory = DefaultLogEventFactory.newInstance();
239+
this.logEventFactory = DI.createInitializedFactory().getInstance(ReusableLogEventFactory.class);
239240
this.name = name;
240241
this.level = level;
241242
this.additive = additive;
@@ -256,7 +257,9 @@ protected LoggerConfig(
256257
final boolean includeLocation,
257258
final LogEventFactory logEventFactory) {
258259
super(filter, null);
259-
this.logEventFactory = logEventFactory != null ? logEventFactory : DefaultLogEventFactory.newInstance();
260+
this.logEventFactory = logEventFactory != null
261+
? logEventFactory
262+
: DI.createInitializedFactory().getInstance(ReusableLogEventFactory.class);
260263
this.name = name;
261264
this.appenderRefs = appenders;
262265
this.level = level;

log4j-core/src/main/java/org/apache/logging/log4j/core/impl/DefaultLogEventFactory.java

Lines changed: 0 additions & 126 deletions
This file was deleted.

log4j-script/src/test/java/org/apache/logging/log4j/script/appender/routing/RoutesScriptAppenderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.apache.logging.log4j.core.appender.routing.Routes;
3131
import org.apache.logging.log4j.core.appender.routing.RoutingAppender;
3232
import org.apache.logging.log4j.core.config.AppenderControl;
33-
import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
33+
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
3434
import org.apache.logging.log4j.core.test.appender.ListAppender;
3535
import org.apache.logging.log4j.core.test.categories.Scripts;
3636
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
@@ -143,7 +143,7 @@ public void testRoutingAppenderRoutes() {
143143
Assert.assertNotNull(routes);
144144
Assert.assertNotNull(routes.getPatternScript());
145145
final LogEvent logEvent =
146-
DefaultLogEventFactory.newInstance().createEvent("", null, "", Level.ERROR, null, null, null);
146+
Log4jLogEvent.newBuilder().setLevel(Level.ERROR).build();
147147
assertEquals("Service2", routes.getPattern(logEvent, new ConcurrentHashMap<>()));
148148
}
149149

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://logging.apache.org/log4j/changelog"
4+
xsi:schemaLocation="http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.3.xsd"
5+
type="removed">
6+
<description format="asciidoc">
7+
Remove `DefaultLogEventFactory`
8+
</description>
9+
</entry>

src/site/_release-notes/_3.x.x.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This release contains...
4747
[#release-notes-3-x-x-removed]
4848
=== Removed
4949
50+
* Remove `DefaultLogEventFactory`
5051
* Remove `org.apache.logging.log4j.core.parser` and related packages. (https://github.com/apache/logging-log4j2/pull/2154[2154])
5152
* Remove `log4j2.enable.threadlocals` property (https://github.com/apache/logging-log4j2/issues/2105[2105])
5253

0 commit comments

Comments
 (0)