Class LoggingConfig

java.lang.Object
com.digitizer.logging.LoggingConfig

public final class LoggingConfig extends Object
Central logging configuration metadata for the Graph Digitizer application.

This class exposes constants that mirror settings in log4j2.xml so other components can reference log file locations without hard-coding duplicate strings. It does not mutate Log4j2 configuration at runtime; Log4j2 picks up its XML configuration during initialization.

Async Logging: To enable high-throughput asynchronous logging, start the JVM with the system property:

   -DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
 
This engages the <AsyncRoot> logger defined in log4j2.xml. Ensure the LMAX Disruptor dependency is present (declared in the Maven pom.xml).

JSON Logs: Structured events are written to the file referenced by JSON_LOG_FILE. Each line is a standalone JSON object suitable for ingestion by log processors (e.g., ELK, Splunk) using a newline-delimited JSON parser.

  • Field Details

  • Method Details

    • logStartupBanner

      public static void logStartupBanner(String appVersion)
      Emits a diagnostic message confirming logging backend activation. Intended for optional startup health checks.
      Parameters:
      appVersion - the application version string to include in the banner
    • initializeMdc

      public static void initializeMdc(String sessionId, String userId)
      Initialize basic MDC (Mapped Diagnostic Context) keys used for correlation. This attaches a session identifier and (optionally) a user id if supplied.
      Parameters:
      sessionId - unique identifier for this application run (e.g. timestamp or random UUID)
      userId - optional user id (null if not applicable)
    • runEnvironmentChecks

      public static void runEnvironmentChecks()
      Performs lightweight environment checks and logs findings:
      • Java version
      • Async logger property presence
      • Log directory existence / creation
    • generateSessionId

      public static String generateSessionId()
      Convenience method to generate a simple session identifier based on current timestamp.
      Returns:
      session id string