File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed
java/org/apache/logging/log4j/core/appender
log4j-core/src/main/java/org/apache/logging/log4j/core/appender Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -151,4 +151,11 @@ public void testShutdownTimeout(final LoggerContext context) {
151151 context .getLogger ("Logger" ).info ("This is a test" );
152152 context .stop ();
153153 }
154+
155+ @ Test
156+ @ LoggerContextSource ("log4j-asynch-location.xml" )
157+ public void testRequiresLocation (final LoggerContext context ) {
158+ final AsyncAppender appender = context .getConfiguration ().getAppender ("Async" );
159+ assertTrue (appender .requiresLocation ());
160+ }
154161}
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 @@ -427,4 +427,9 @@ public int getQueueRemainingCapacity() {
427427 public int getQueueSize () {
428428 return queue .size ();
429429 }
430+
431+ @ Override
432+ public boolean requiresLocation () {
433+ return includeLocation && dispatcher .requiresLocation ();
434+ }
430435}
Original file line number Diff line number Diff line change @@ -167,4 +167,13 @@ void stop(final long timeoutMillis) throws InterruptedException {
167167 // Wait for the completion.
168168 join (timeoutMillis );
169169 }
170+
171+ boolean requiresLocation () {
172+ for (var appender : appenders ) {
173+ if (appender .getAppender ().requiresLocation ()) {
174+ return true ;
175+ }
176+ }
177+ return errorAppender != null && errorAppender .getAppender ().requiresLocation ();
178+ }
170179}
You can’t perform that action at this time.
0 commit comments