@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 2024 the original author or authors .
* Copyright 2012 - 2025 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -17,6 +17,7 @@
@@ -17,6 +17,7 @@
package org.springframework.boot.logging.log4j2 ;
import java.io.IOException ;
import java.io.InputStream ;
import java.net.URL ;
import java.net.URLConnection ;
import java.util.ArrayList ;
@ -278,13 +279,11 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem {
@@ -278,13 +279,11 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem {
private Configuration load ( String location , LoggerContext context ) throws IOException {
Resource resource = new ApplicationResourceLoader ( ) . getResource ( location ) ;
ConfigurationSource source = getConfigurationSource ( resource ) ;
return ConfigurationFactory . getInstance ( ) . getConfiguration ( context , source ) ;
}
private ConfigurationSource getConfigurationSource ( Resource resource ) throws IOException {
ConfigurationFactory factory = ConfigurationFactory . getInstance ( ) ;
if ( resource . isFile ( ) ) {
return new ConfigurationSource ( resource . getInputStream ( ) , resource . getFile ( ) ) ;
try ( InputStream inputStream = resource . getInputStream ( ) ) {
return factory . getConfiguration ( context , new ConfigurationSource ( inputStream , resource . getFile ( ) ) ) ;
}
}
URL url = resource . getURL ( ) ;
AuthorizationProvider authorizationProvider = ConfigurationFactory
@ -293,7 +292,10 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem {
@@ -293,7 +292,10 @@ public class Log4J2LoggingSystem extends AbstractLoggingSystem {
? SslConfigurationFactory . getSslConfiguration ( ) : null ;
URLConnection connection = UrlConnectionFactory . createConnection ( url , 0 , sslConfiguration ,
authorizationProvider ) ;
return new ConfigurationSource ( connection . getInputStream ( ) , url , connection . getLastModified ( ) ) ;
try ( InputStream inputStream = connection . getInputStream ( ) ) {
return factory . getConfiguration ( context ,
new ConfigurationSource ( inputStream , url , connection . getLastModified ( ) ) ) ;
}
}
private CompositeConfiguration createComposite ( List < Configuration > configurations ) {