Problem Statement
Currently, our JUL logging implementation doesn't follow Oracle's official guidelines and lacks compatibility considerations for teams using SLF4J/Log4j bridges and cloud log filtering.
Proposed Solution
Implement a refined JUL logging strategy that aligns with Oracle's official documentation while providing practical compatibility for teams expecting traditional ERROR level messages.
Key Requirements
1. ERROR Prefix for SEVERE Level
IMPORTANT: Since JUL is widely bridged to SLF4J and teams often filter on ERROR strings (not SEVERE), prefix SEVERE level messages with "ERROR:" for cloud log monitoring compatibility.
LOG.severe(() -> "ERROR: Remote references disabled but computeIfAbsent called for: " + key);
Apply ERROR prefix only for:
- Logging before throwing exceptions
- Clear validation issues
- Cases where SLF4J/Log4j users would typically log at
error level
- Messages that cloud log filters should catch for monitoring
2. Performance Warning Prefix
Use consistent "PERFORMANCE WARNING:" prefix for potential performance issues (which Oracle guidelines specify should use FINE level):
// Oracle guidelines: FINE (500) is appropriate for "potential performance problems"
LOG.fine(() -> "PERFORMANCE WARNING: Validation stack processing " + count + " items exceeds recommended threshold of " + threshold);
3. Oracle JUL Level Hierarchy
Follow Oracle's official target-audience-based hierarchy:
- SEVERE (1000): Serious failures preventing normal execution + ERROR prefix when appropriate
- WARNING (900): Potential problems for end users/system managers
- INFO (800): Reasonably significant messages for end users/administrators (use sparingly)
- CONFIG (700): Static configuration information for debugging setup issues
- FINE (500): Developer debugging info, minor recoverable failures, performance warnings
- FINER (400): Detailed tracing, method entry/exit, exception throwing
- FINEST (300): Maximum detail debugging, data structures, wire protocol data
4. Lambda-Based Logging Only
ALL logging must use lambda expressions to ensure zero runtime overhead when log levels are disabled. The JVM optimizes away unused lambda branches automatically.
Implementation Tasks
Examples of Level Usage
// SEVERE with ERROR prefix - prevents normal execution
LOG.severe(() -> "ERROR: Failed to compile JSON schema: " + schemaUri);
// WARNING - recoverable issue
LOG.warning(() -> "Deprecated schema version detected, using compatibility mode");
// INFO - significant but not noisy
LOG.info(() -> "JSON schema validator initialized with " + schemaCount + " schemas");
// CONFIG - configuration details
LOG.config(() -> "Validation features enabled: " + Arrays.toString(enabledFeatures));
// FINE - developer debugging and performance warnings
LOG.fine(() -> "PERFORMANCE WARNING: Deep recursion detected at depth " + depth);
LOG.fine(() -> "Schema cache miss for: " + schemaId);
// FINER - detailed tracing
LOG.finer(() -> "Entering validation method for schema: " + schemaType);
// FINEST - maximum detail (JVM optimizes away when disabled)
LOG.finest(() -> "Raw JSON data: " + jsonData);
LOG.finest(() -> "Expensive debug info: " + computeExpensiveDebugString());
Rationale
This approach provides:
- Oracle compliance: Follows official JUL documentation
- Practical compatibility: ERROR prefix ensures cloud log monitoring works
- Performance awareness: Consistent PERFORMANCE WARNING prefix for threshold issues
- Zero runtime overhead: Lambda expressions eliminate performance impact of disabled logging
- Developer productivity: Clear level hierarchy for different debugging needs
- Library best practices: Conservative logging appropriate for library consumers
Acceptance Criteria
Problem Statement
Currently, our JUL logging implementation doesn't follow Oracle's official guidelines and lacks compatibility considerations for teams using SLF4J/Log4j bridges and cloud log filtering.
Proposed Solution
Implement a refined JUL logging strategy that aligns with Oracle's official documentation while providing practical compatibility for teams expecting traditional
ERRORlevel messages.Key Requirements
1. ERROR Prefix for SEVERE Level
IMPORTANT: Since JUL is widely bridged to SLF4J and teams often filter on
ERRORstrings (notSEVERE), prefix SEVERE level messages with "ERROR:" for cloud log monitoring compatibility.Apply ERROR prefix only for:
errorlevel2. Performance Warning Prefix
Use consistent "PERFORMANCE WARNING:" prefix for potential performance issues (which Oracle guidelines specify should use FINE level):
3. Oracle JUL Level Hierarchy
Follow Oracle's official target-audience-based hierarchy:
4. Lambda-Based Logging Only
ALL logging must use lambda expressions to ensure zero runtime overhead when log levels are disabled. The JVM optimizes away unused lambda branches automatically.
Implementation Tasks
Examples of Level Usage
Rationale
This approach provides:
Acceptance Criteria