GoWindGoWind
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
  • Introduction

    • GoWind Framework
    • Framework Architecture
  • go-wind Core

    • go-wind Core Framework
    • App Lifecycle Management
    • Context Propagation
    • Transport Abstraction
    • Log Facade Interface
  • go-wind-plugins

    • go-wind-plugins Plugin Overview
    • Plugin Configuration System
    • Plugin Registration Mechanism (SPI)
    • Logging Adapter Plugins
    • Transport Protocol Plugins
    • Message Middleware Plugins
    • Encoding Plugins
    • Security and Authentication Plugins
    • Distributed Tracing Plugins
    • Cache Plugins
    • Object Storage Plugins (OSS)
    • Rate Limiting Plugins
    • Metrics Plugins
    • AI Plugins
    • Workflow Plugins
    • Database and Cache Plugins
    • Bootstrap Integration and Gateway Plugins
    • Compression and Serialization Plugins
    • Template Rendering and Validation Plugins
  • go-wind-bootstrap

    • go-wind-bootstrap: The Declarative Bootstrap
    • The Bootstrap Configuration System
    • The Bootstrap SPI Mechanism
    • Declarative Middleware Orchestration
    • Bootstrap Command-Line Integration
    • Bootstrap Practical Examples
  • go-wind-flow Workflow Engine

    • GoWind Flow Process Engine
  • Tutorials

    • Quick Start Tutorial
    • Custom Plugin Development Tutorial
    • Multi-Protocol Listening Tutorial
    • Framework Migration Guide

Logging Adapter Plugins

go-wind-plugins provides a variety of logging adapters implementing the log.Logger interface. Each adapter wraps the native logger of its logging engine, so business code goes through the unified log.Logger facade.

1. Adapter List

AdapterImport PathEngine
Zapplugins/log/zapuber-go/zap
Zerologplugins/log/zerologrs/zerolog
Logrusplugins/log/logrussirupsen/logrus
Phusluplugins/log/phusluphuslu/log
Charmplugins/log/charmcharmbracelet/log
Glogplugins/log/gloggolang/glog
Hclogplugins/log/hcloghashicorp/go-hclog
Lokiplugins/log/lokiGrafana Loki
Fluentplugins/log/fluentFluentd
Sentryplugins/log/sentrygetsentry/sentry-go
CloudWatchplugins/log/cloudwatchAWS CloudWatch Logs
Aliyun SLSplugins/log/aliyunAlibaba Cloud Log Service SLS
Tencent CLSplugins/log/tencentTencent Cloud Log Service CLS

The log/ root package also ships with: a slog adapter (the default Logger), a LevelFilter log-level filter, and MultiLogger, a multiplexing logger that writes one log entry to multiple backends simultaneously.

2. Zap Adapter

2.1 Basic Usage

import (
    "context"

    zap "go.uber.org/zap"
    zaplog "github.com/tx7do/go-wind-plugins/log/zap"
)

// Build the native zap.Logger first, then wrap it into the unified log.Logger
zlog, _ := zap.NewProduction()
logger := zaplog.NewZapLogger(zlog)
defer logger.Close()

logger.Info(context.Background(), "service started", "port", 8080)
logger.With("module", "auth").Error(context.Background(), "token expired")

2.2 YAML Configuration (bootstrap wiring)

2.3 YAML Configuration

log:
  zap:
    level: info
    format: json
    output: stdout
    # file logging
    file:
      enabled: true
      filename: logs/app.log
      max_size: 100        # MB
      max_backups: 7
      max_age: 30          # days
      compress: true

3. Zerolog Adapter

import _ "github.com/tx7do/go-wind-plugins/log/zerolog"
log:
  zerolog:
    level: info
    format: json           # zerolog defaults to JSON
    output: stdout
    time_format: rfc3339   # unix | rfc3339 | rfc3339nano
    no_color: false

Highlights:

  • Zero allocations, extremely high performance
  • Native JSON output
  • Well suited for high-throughput scenarios

4. Logrus Adapter

import _ "github.com/tx7do/go-wind-plugins/log/logrus"
log:
  logrus:
    level: info
    format: text           # text | json
    output: stdout
    report_caller: true
    full_timestamp: true

Highlights:

  • The richest community ecosystem
  • Extensible via the hook mechanism
  • The best compatibility

5. Loki Remote Logging

import _ "github.com/tx7do/go-wind-plugins/log/loki"
log:
  loki:
    level: info
    url: "http://loki:3100/loki/api/v1/push"
    labels:
      service: my-service
      env: production
    batch_size: 100
    batch_timeout: 5s
    buffer_size: 10000

Highlights:

  • Pushes logs directly to Grafana Loki
  • Supports label-based filtering
  • Batches pushes to reduce network overhead

6. Sentry Error Tracking

import _ "github.com/tx7do/go-wind-plugins/log/sentry"
log:
  sentry:
    level: error           # reports error level and above only
    dsn: "https://xxx@sentry.io/123"
    environment: production
    release: "v1.0.0"
    sample_rate: 1.0       # sampling rate

Highlights:

  • Reports error level and above to Sentry
  • Automatically captures stack traces
  • Supports sampling-rate control

7. CloudWatch

import _ "github.com/tx7do/go-wind-plugins/log/cloudwatch"
log:
  cloudwatch:
    level: info
    region: us-east-1
    log_group: /ecs/my-service
    log_stream: app-2024-01-01
    batch_size: 100
    batch_timeout: 5s

8. Aliyun SLS and Tencent Cloud CLS

import _ "github.com/tx7do/go-wind-plugins/log/aliyun"   // Alibaba Cloud SLS
import _ "github.com/tx7do/go-wind-plugins/log/tencent"  // Tencent Cloud CLS
log:
  aliyun:
    level: info
    endpoint: "cn-hangzhou.log.aliyuncs.com"
    project: my-project
    logstore: app-logs
    access_key_id: ${ALIYUN_AK}
    access_key_secret: ${ALIYUN_SK}

  tencent:
    level: info
    endpoint: "ap-guangzhou.cls.tencentcs.com"
    topic_id: my-topic-id
    secret_id: ${TENCENT_SECRET_ID}
    secret_key: ${TENCENT_SECRET_KEY}

9. Performance Comparison

AdapterThroughput (ops/s)Allocations/opTypical Use
Zap~2,000,0000High-performance services
Zerolog~2,500,0000Ultra-high throughput
Logrus~300,0005General purpose
Lokinetwork-boundN/ALog aggregation
Sentrynetwork-boundN/AError monitoring

Related Documents

  • Log Facade Interface
  • Plugin Configuration System
  • Plugin Overview
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Prev
Plugin Registration Mechanism (SPI)
Next
Transport Protocol Plugins