File tree Expand file tree Collapse file tree 4 files changed +69
-0
lines changed
log4j-core/src/main/java/org/apache/logging/log4j/core/appender
java/org/apache/logging/log4j/core/appender Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -174,4 +174,11 @@ void testShutdownTimeout(final LoggerContext context) {
174
174
context .getLogger ("Logger" ).info ("This is a test" );
175
175
context .stop ();
176
176
}
177
+
178
+ @ Test
179
+ @ LoggerContextSource ("log4j-asynch-location.xml" )
180
+ public void testRequiresLocation (final LoggerContext context ) {
181
+ final AsyncAppender appender = context .getConfiguration ().getAppender ("Async" );
182
+ assertTrue (appender .requiresLocation ());
183
+ }
177
184
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <!--
3
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
4
+ ~ contributor license agreements. See the NOTICE file distributed with
5
+ ~ this work for additional information regarding copyright ownership.
6
+ ~ The ASF licenses this file to you under the Apache License, Version 2.0
7
+ ~ (the "License"); you may not use this file except in compliance with
8
+ ~ the License. You may obtain a copy of the License at
9
+ ~
10
+ ~ http://www.apache.org/licenses/LICENSE-2.0
11
+ ~
12
+ ~ Unless required by applicable law or agreed to in writing, software
13
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
14
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ ~ See the License for the specific language governing permissions and
16
+ ~ limitations under the License.
17
+ -->
18
+ <Configuration status =" OFF" >
19
+
20
+ <Appenders >
21
+ <Console name =" STDOUT" >
22
+ <PatternLayout pattern =" %m%L%n" />
23
+ </Console >
24
+ <Async name =" Async" includeLocation =" true" >
25
+ <AppenderRef ref =" STDOUT" />
26
+ </Async >
27
+ </Appenders >
28
+
29
+ <Loggers >
30
+ <Root level =" debug" includeLocation =" true" >
31
+ <AppenderRef ref =" Async" />
32
+ </Root >
33
+ </Loggers >
34
+
35
+ </Configuration >
Original file line number Diff line number Diff line change 47
47
import org .apache .logging .log4j .core .config .plugins .PluginElement ;
48
48
import org .apache .logging .log4j .core .config .plugins .validation .constraints .Required ;
49
49
import org .apache .logging .log4j .core .filter .AbstractFilterable ;
50
+ import org .apache .logging .log4j .core .impl .LocationAware ;
50
51
import org .apache .logging .log4j .core .impl .Log4jLogEvent ;
51
52
import org .apache .logging .log4j .spi .AbstractLogger ;
52
53
@@ -471,4 +472,22 @@ public int getQueueRemainingCapacity() {
471
472
public int getQueueSize () {
472
473
return queue .size ();
473
474
}
475
+
476
+ @ Override
477
+ public boolean requiresLocation () {
478
+ if (!includeLocation ) {
479
+ return false ;
480
+ }
481
+ for (final Appender appender : this .getAppenders ()) {
482
+ if (appender instanceof LocationAware && ((LocationAware ) appender ).requiresLocation ()) {
483
+ return true ;
484
+ }
485
+ }
486
+ if (errorAppender != null
487
+ && errorAppender .getAppender () instanceof LocationAware
488
+ && ((LocationAware ) errorAppender .getAppender ()).requiresLocation ()) {
489
+ return true ;
490
+ }
491
+ return false ;
492
+ }
474
493
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <entry xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xmlns =" https://logging.apache.org/xml/ns"
4
+ xsi : schemaLocation =" https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
5
+ type =" fixed" >
6
+ <issue id =" 3257" link =" https://github.com/apache/logging-log4j2/issues/3257" />
7
+ <description format =" asciidoc" >Fix detection of location requirements in `AsyncAppender`.</description >
8
+ </entry >
You can’t perform that action at this time.
0 commit comments