iotdb icon indicating copy to clipboard operation
iotdb copied to clipboard

Fix enable_audit_log configuration not taking effect

Open zhan7236 opened this issue 4 weeks ago • 0 comments

Description

This PR fixes the issue where the enable_audit_log configuration was not taking effect, causing audit logs to always remain disabled even when explicitly set to true.

Fixes: https://github.com/apache/iotdb/issues/16706

Root Cause

The audit log configuration values were defined as static final fields in AbstractAuditLogger:

protected static final boolean IS_AUDIT_LOG_ENABLED = CONFIG.isEnableAuditLog();
private static final List<AuditLogOperation> AUDITABLE_OPERATION_TYPE = CONFIG.getAuditableOperationType();
private static final PrivilegeLevel AUDITABLE_OPERATION_LEVEL = CONFIG.getAuditableOperationLevel();
private static final String AUDITABLE_OPERATION_RESULT = CONFIG.getAuditableOperationResult();

These static final fields are initialized at class loading time, which may occur before the configuration file is fully loaded (especially in Docker environments where configuration is injected via environment variables). As a result, these values always get the default value (false for enable_audit_log).

Solution

Changed the static final fields to dynamic method calls that read the configuration values at runtime:

  • IS_AUDIT_LOG_ENABLEDisAuditLogEnabled() method
  • AUDITABLE_OPERATION_TYPEgetAuditableOperationType() method
  • AUDITABLE_OPERATION_LEVELgetAuditableOperationLevel() method
  • AUDITABLE_OPERATION_RESULTgetAuditableOperationResult() method

This ensures that the configuration values are read dynamically after the configuration file has been properly loaded.

Changed Files

  • AbstractAuditLogger.java
  • DNAuditLogger.java
  • CNAuditLogger.java

Testing

  • [x] Code compiles successfully
  • [x] Code style check passed (mvn spotless:check)

Checklist

  • [x] I have read the Contributing Guidelines
  • [x] I have searched for similar issues before creating this PR
  • [x] The code follows the project's coding style

zhan7236 avatar Nov 30 '25 17:11 zhan7236