public class Log4jAuditService extends Object implements AuditService
| Modifier and Type | Field and Description |
|---|---|
static String |
MDC_AUDIT_CONTEXT_KEY |
| Constructor and Description |
|---|
Log4jAuditService() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachContext(AuditContext context)
Attaches the provided audit context to the current thread.
|
AuditContext |
createContext()
Creates and attaches an "empty" audit context.
|
AuditContext |
detachContext()
Detaches the current audit context, if any, from the current thread.
|
<T> T |
execute(AuditContext context,
Callable<T> callable)
Executes the callable within the provided audit context.
|
Auditor |
getAuditor(String auditorName,
String componentName,
String serviceName)
Retrieves an auditor configured with the the provided component and service names.
|
AuditContext |
getContext()
Retrieves the current attached audit context, if any.
|
public static final String MDC_AUDIT_CONTEXT_KEY
public AuditContext createContext()
AuditServicecreateContext in interface AuditServicepublic AuditContext getContext()
AuditServicegetContext in interface AuditServicepublic void attachContext(AuditContext context)
AuditServiceattachContext in interface AuditServicecontext - The audit context to attach to the current thread. May be null.public AuditContext detachContext()
AuditServicedetachContext in interface AuditServicepublic <T> T execute(AuditContext context, Callable<T> callable) throws Exception
AuditServiceexecute in interface AuditServiceT - Type of callablecontext - The context to establish around the invocation of the callable. May not be null.callable - The callable to invoke after establishing the correlation context. May not be null.Exception - Thrown if thrown by the callable's call method.public Auditor getAuditor(String auditorName, String componentName, String serviceName)
AuditServicegetAuditor in interface AuditServiceauditorName - The name of auditor. Can be used to separate audit events to different destinations. For example security audit, operations audit, etccomponentName - The name of component that will be placed used in every audit event generated by Auditor instanceserviceName - The name of service that will be placed used in every audit event generated by Auditor instanceCopyright © 2022 The Apache Software Foundation. All rights reserved.