Package cloud.opencode.base.log


package cloud.opencode.base.log
OpenCode Base Log - Lightweight Logging Facade OpenCode 基础日志 - 轻量级日志门面

This package provides a lightweight logging facade with SPI mechanism for pluggable log engines. It supports multiple logging frameworks like SLF4J, Log4j2, and JUL through a unified API.

本包提供轻量级日志门面,支持 SPI 可插拔日志引擎。 通过统一 API 支持 SLF4J、Log4j2、JUL 等多种日志框架。

Key Features | 核心特性

  • Zero-configuration static logging via OpenLog
  • Instance-based logging via LoggerFactory
  • Lambda lazy evaluation for expensive log messages
  • MDC/NDC context management
  • Marker-based categorization
  • Performance logging with StopWatch
  • Audit logging for compliance
  • Structured JSON logging
  • Data masking for sensitive information
  • Sampled logging for high-frequency events

Quick Start | 快速开始

// Static logging (zero-config)
import static cloud.opencode.base.log.OpenLog.*;

info("Application started");
warn("Low memory: {}MB", availableMemory);
error("Failed to connect", exception);

// Instance-based logging
Logger log = LoggerFactory.getLogger(MyClass.class);
log.info("Processing request: {}", requestId);

// Lambda lazy evaluation
log.debug(() -> "Expensive: " + computeExpensiveValue());

Package Structure | 包结构

  • cloud.opencode.base.log - Core logging classes
  • cloud.opencode.base.log.spi - SPI interfaces and providers
  • cloud.opencode.base.log.context - MDC/NDC context management
  • cloud.opencode.base.log.marker - Marker support
  • cloud.opencode.base.log.perf - Performance logging
  • cloud.opencode.base.log.audit - Audit logging
  • cloud.opencode.base.log.enhance - Enhanced logging features
  • cloud.opencode.base.log.exception - Exception classes
Since:
JDK 25, opencode-base-log V1.0.0
Author:
OpenCode Cloud Group
See Also:
  • Class
    Description
    Caller Information Record - Captures Stack Frame Location 调用者信息记录 - 捕获堆栈帧位置
    Log Event Record - Immutable Representation of a Log Entry 日志事件记录 - 日志条目的不可变表示
    Log Event Builder - Fluent Builder for LogEvent Construction 日志事件构建器 - LogEvent 的流式构建器
    Logger Interface - Core Logging Contract 日志记录器接口 - 核心日志契约
    Logger Factory - Factory for Creating Logger Instances 日志工厂 - 创建日志记录器实例的工厂
    Log Level Enumeration - Defines Standard Log Levels 日志级别枚举 - 定义标准日志级别
    OpenLog - Unified Logging Facade OpenLog - 统一日志门面