Package org.keycloak.services.logging
Class DefaultMappedDiagnosticContextProviderFactory
java.lang.Object
org.keycloak.services.logging.DefaultMappedDiagnosticContextProviderFactory
- All Implemented Interfaces:
MappedDiagnosticContextProvider,MappedDiagnosticContextProviderFactory,EnvironmentDependentProviderFactory,Provider,ProviderFactory<MappedDiagnosticContextProvider>
public class DefaultMappedDiagnosticContextProviderFactory
extends Object
implements MappedDiagnosticContextProviderFactory, MappedDiagnosticContextProvider, EnvironmentDependentProviderFactory
The default provider factory can be configured via --spi-mapped-diagnostic-context-default-mdc-keys to define mdc
keys to add as a comma-separated list. By default, "realm", "clientId", "userId", "ipAddress" and "org" are supported by the default provider implementation.
If you need further keys, you need to extend the provider.
- Author:
- Björn Eickvonder
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface org.keycloak.logging.MappedDiagnosticContextProvider
MDC_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This is called when the server shuts down.create(KeycloakSession session) Returns the metadata for each configuration property supported by this factory.getId()voidinit(Config.Scope config) Only called once when the factory is first created.booleanisSupported(Config.Scope config) Check if the provider is supported and should be available based on the provider configuration.voidpostInit(KeycloakSessionFactory factory) Called after all provider factories have been initializedprotected voidvoidupdate(KeycloakContext keycloakContext, ClientModel client) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.voidupdate(KeycloakContext keycloakContext, OrganizationModel organization) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.voidupdate(KeycloakContext keycloakContext, RealmModel realm) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.voidupdate(KeycloakContext keycloakContext, UserSessionModel userSession) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.voidupdate(KeycloakContext keycloakContext, AuthenticationSessionModel session) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.provider.ProviderFactory
dependsOn, order
-
Field Details
-
MDC_KEY_REALM_NAME
- See Also:
-
MDC_KEY_CLIENT_ID
- See Also:
-
MDC_KEY_USER_ID
- See Also:
-
MDC_KEY_IP_ADDRESS
- See Also:
-
MDC_KEY_ORGANIZATION
- See Also:
-
MDC_KEY_SESSION_ID
- See Also:
-
MDC_KEY_AUTHENTICATION_SESSION_ID
- See Also:
-
MDC_KEY_AUTHENTICATION_TAB_ID
- See Also:
-
MDC_KEYS
- See Also:
-
-
Constructor Details
-
DefaultMappedDiagnosticContextProviderFactory
public DefaultMappedDiagnosticContextProviderFactory()
-
-
Method Details
-
create
- Specified by:
createin interfaceProviderFactory<MappedDiagnosticContextProvider>
-
init
Description copied from interface:ProviderFactoryOnly called once when the factory is first created.- Specified by:
initin interfaceProviderFactory<MappedDiagnosticContextProvider>
-
postInit
Description copied from interface:ProviderFactoryCalled after all provider factories have been initialized- Specified by:
postInitin interfaceProviderFactory<MappedDiagnosticContextProvider>
-
close
public void close()Description copied from interface:ProviderFactoryThis is called when the server shuts down.- Specified by:
closein interfaceProvider- Specified by:
closein interfaceProviderFactory<MappedDiagnosticContextProvider>
-
getId
- Specified by:
getIdin interfaceProviderFactory<MappedDiagnosticContextProvider>
-
getConfigMetadata
Description copied from interface:ProviderFactoryReturns the metadata for each configuration property supported by this factory.- Specified by:
getConfigMetadatain interfaceProviderFactory<MappedDiagnosticContextProvider>- Returns:
- a list with the metadata for each configuration property supported by this factory
-
isSupported
Description copied from interface:EnvironmentDependentProviderFactoryCheck if the provider is supported and should be available based on the provider configuration.- Specified by:
isSupportedin interfaceEnvironmentDependentProviderFactory- Parameters:
config- the provider configuration- Returns:
trueif the provider is supported. Otherwise,false.
-
update
Description copied from interface:MappedDiagnosticContextProviderUpdates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context. This method is called when a Keycloak Session is set and when the authentication session property of the Keycloak context is updated.- Specified by:
updatein interfaceMappedDiagnosticContextProvider- Parameters:
keycloakContext- the current Keycloak context, never nullsession- the authentication session
-
update
Description copied from interface:MappedDiagnosticContextProviderUpdates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context. This method is called when a Keycloak Session is set and when the realm property of the Keycloak context is updated.- Specified by:
updatein interfaceMappedDiagnosticContextProvider- Parameters:
keycloakContext- the current Keycloak context, never nullrealm- the realm
-
update
Description copied from interface:MappedDiagnosticContextProviderUpdates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context. This method is called when a Keycloak Session is set and when the client property of the Keycloak context is updated.- Specified by:
updatein interfaceMappedDiagnosticContextProvider- Parameters:
keycloakContext- the current Keycloak context, never nullclient- the client
-
update
Description copied from interface:MappedDiagnosticContextProviderUpdates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context. This method is called when a Keycloak Session is set and when the organization property of the Keycloak context is updated.- Specified by:
updatein interfaceMappedDiagnosticContextProvider- Parameters:
keycloakContext- the current Keycloak context, never nullorganization- the organization
-
update
Description copied from interface:MappedDiagnosticContextProviderUpdates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context. This method is called when a Keycloak Session is set and when the user session property of the Keycloak context is updated.- Specified by:
updatein interfaceMappedDiagnosticContextProvider- Parameters:
keycloakContext- the current Keycloak context, never nulluserSession- the user session
-
putMdc
-