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 String
static final String
static final String
static final String
static final String
static final String
Fields inherited from interface org.keycloak.logging.MappedDiagnosticContextProvider
MDC_PREFIX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is called when the server shuts down.create
(KeycloakSession session) Returns the metadata for each configuration property supported by this factory.getId()
void
init
(Config.Scope config) Only called once when the factory is first created.boolean
isSupported
(Config.Scope config) Check if the provider is supported and should be available based on the provider configuration.void
postInit
(KeycloakSessionFactory factory) Called after all provider factories have been initializedprotected void
void
update
(KeycloakContext keycloakContext, ClientModel client) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.void
update
(KeycloakContext keycloakContext, OrganizationModel organization) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.void
update
(KeycloakContext keycloakContext, RealmModel realm) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.void
update
(KeycloakContext keycloakContext, UserSessionModel userSession) Updates the Mapped Diagnostic Context (MDC) with key/value pairs based on the current Keycloak context.void
update
(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, wait
Methods inherited from interface org.keycloak.provider.ProviderFactory
dependsOn, order
-
Field Details
-
MDC_KEY_REALM
- 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_KEYS
- See Also:
-
-
Constructor Details
-
DefaultMappedDiagnosticContextProviderFactory
public DefaultMappedDiagnosticContextProviderFactory()
-
-
Method Details
-
create
- Specified by:
create
in interfaceProviderFactory<MappedDiagnosticContextProvider>
-
init
Description copied from interface:ProviderFactory
Only called once when the factory is first created. This config is pulled from keycloak_server.json- Specified by:
init
in interfaceProviderFactory<MappedDiagnosticContextProvider>
-
postInit
Description copied from interface:ProviderFactory
Called after all provider factories have been initialized- Specified by:
postInit
in interfaceProviderFactory<MappedDiagnosticContextProvider>
-
close
public void close()Description copied from interface:ProviderFactory
This is called when the server shuts down.- Specified by:
close
in interfaceProvider
- Specified by:
close
in interfaceProviderFactory<MappedDiagnosticContextProvider>
-
getId
- Specified by:
getId
in interfaceProviderFactory<MappedDiagnosticContextProvider>
-
getConfigMetadata
Description copied from interface:ProviderFactory
Returns the metadata for each configuration property supported by this factory.- Specified by:
getConfigMetadata
in interfaceProviderFactory<MappedDiagnosticContextProvider>
- Returns:
- a list with the metadata for each configuration property supported by this factory
-
isSupported
Description copied from interface:EnvironmentDependentProviderFactory
Check if the provider is supported and should be available based on the provider configuration.- Specified by:
isSupported
in interfaceEnvironmentDependentProviderFactory
- Parameters:
config
- the provider configuration- Returns:
true
if the provider is supported. Otherwise,false
.
-
update
Description copied from interface:MappedDiagnosticContextProvider
Updates 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:
update
in interfaceMappedDiagnosticContextProvider
- Parameters:
keycloakContext
- the current Keycloak context, never nullsession
- the authentication session
-
update
Description copied from interface:MappedDiagnosticContextProvider
Updates 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:
update
in interfaceMappedDiagnosticContextProvider
- Parameters:
keycloakContext
- the current Keycloak context, never nullrealm
- the realm
-
update
Description copied from interface:MappedDiagnosticContextProvider
Updates 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:
update
in interfaceMappedDiagnosticContextProvider
- Parameters:
keycloakContext
- the current Keycloak context, never nullclient
- the client
-
update
Description copied from interface:MappedDiagnosticContextProvider
Updates 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:
update
in interfaceMappedDiagnosticContextProvider
- Parameters:
keycloakContext
- the current Keycloak context, never nullorganization
- the organization
-
update
Description copied from interface:MappedDiagnosticContextProvider
Updates 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:
update
in interfaceMappedDiagnosticContextProvider
- Parameters:
keycloakContext
- the current Keycloak context, never nulluserSession
- the user session
-
putMdc
-