-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix 1799 and Spring 33450 #2062
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to you under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.logging.log4j.core; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.core.impl.Log4jContextFactory; | ||
import org.apache.logging.log4j.core.impl.internal.InternalLoggerContext; | ||
import org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry; | ||
import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry; | ||
import org.apache.logging.log4j.spi.LoggerContextFactory; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Validate Logging after Shutdown. | ||
*/ | ||
public class LoggerContextTest { | ||
|
||
@Test | ||
public void shutdownTest() { | ||
LoggerContextFactory contextFactory = LogManager.getFactory(); | ||
assertTrue(contextFactory instanceof Log4jContextFactory); | ||
Log4jContextFactory factory = (Log4jContextFactory) contextFactory; | ||
ShutdownCallbackRegistry registry = factory.getShutdownCallbackRegistry(); | ||
assertTrue(registry instanceof DefaultShutdownCallbackRegistry); | ||
((DefaultShutdownCallbackRegistry) registry).start(); | ||
((DefaultShutdownCallbackRegistry) registry).stop(); | ||
LoggerContext loggerContext = factory.getContext(LoggerContextTest.class.getName(), null, null, false); | ||
assertTrue(loggerContext instanceof InternalLoggerContext); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,15 @@ | |
import org.apache.logging.log4j.core.LoggerContext; | ||
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory; | ||
import org.apache.logging.log4j.core.impl.Log4jPropertyKey; | ||
import org.apache.logging.log4j.core.util.AuthorizationProvider; | ||
import org.apache.logging.log4j.plugins.Namespace; | ||
import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory; | ||
import org.apache.logging.log4j.plugins.di.Key; | ||
import org.apache.logging.log4j.plugins.model.PluginNamespace; | ||
import org.apache.logging.log4j.status.StatusLogger; | ||
import org.apache.logging.log4j.util.LoaderUtil; | ||
import org.apache.logging.log4j.util.PropertiesUtil; | ||
import org.apache.logging.log4j.util.PropertyEnvironment; | ||
import org.apache.logging.log4j.util.PropertyKey; | ||
|
||
/** | ||
|
@@ -118,6 +121,15 @@ protected boolean isActive() { | |
return true; | ||
} | ||
|
||
/** | ||
* Required for Spring Boot. | ||
* @param props PropertiesUtil. | ||
* @return the AuthorizationProvider, if any. | ||
*/ | ||
public static AuthorizationProvider authorizationProvider(final PropertiesUtil props) { | ||
return AuthorizationProvider.getAuthorizationProvider((PropertyEnvironment) props); | ||
} | ||
Comment on lines
+129
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not really sure if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that the method should not be duplicated. Also, in order to make this PR back-portable to Unless I am mistaken, all HTTP/HTTPS accesses are performed after a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The authorization provider is always created based on properties, partly because it can be used to authenticate with a remote source that provides your logging config. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ppkarwasz Correct. It is NOT a new method. Matt removed it a few weeks before I made this fix. |
||
|
||
public abstract Configuration getConfiguration(final LoggerContext loggerContext, ConfigurationSource source); | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we better dump
ex
using theStatusLogger
or something else?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. The issue that was reported simply causes error messages to be logged. The application is shutting down so an error during shutdown is irritating. Changing that to a warning doesn't really help much.