{"id":28713495,"url":"https://github.com/go-spring/log","last_synced_at":"2025-06-15T00:10:35.352Z","repository":{"id":298900011,"uuid":"1001276102","full_name":"go-spring/log","owner":"go-spring","description":"A high-performance, tag-based structured logging system with a self4j-inspired architecture.","archived":false,"fork":false,"pushed_at":"2025-06-13T14:10:44.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-13T14:26:51.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-spring.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-13T05:42:17.000Z","updated_at":"2025-06-13T14:10:03.000Z","dependencies_parsed_at":"2025-06-13T14:26:54.890Z","dependency_job_id":"501d78ee-384c-4197-b36a-ff123c3e68e5","html_url":"https://github.com/go-spring/log","commit_stats":null,"previous_names":["go-spring/log"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/go-spring/log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-spring%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-spring%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-spring%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-spring%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-spring","download_url":"https://codeload.github.com/go-spring/log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-spring%2Flog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259804610,"owners_count":22913885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-15T00:10:34.662Z","updated_at":"2025-06-15T00:10:35.302Z","avatar_url":"https://github.com/go-spring.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Spring :: Log\n\n\u003cdiv\u003e\n   \u003cimg src=\"https://img.shields.io/github/license/go-spring/log\" alt=\"license\"/\u003e\n   \u003cimg src=\"https://img.shields.io/github/go-mod/go-version/go-spring/log\" alt=\"go-version\"/\u003e\n   \u003cimg src=\"https://img.shields.io/github/v/release/go-spring/log?include_prereleases\" alt=\"release\"/\u003e\n   \u003ca href=\"https://codecov.io/gh/go-spring/log\" \u003e \n      \u003cimg src=\"https://codecov.io/gh/go-spring/log/graph/badge.svg?token=QBCHVEK97Q\" alt=\"test-coverage\"/\u003e \n   \u003c/a\u003e\n   \u003ca href=\"https://deepwiki.com/go-spring/log\"\u003e\u003cimg src=\"https://deepwiki.com/badge.svg\" alt=\"Ask DeepWiki\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n[English](README.md) | [中文](README_CN.md)\n\n**Go-Spring :: Log** is a high-performance and extensible logging library designed specifically for the Go programming\nlanguage. It offers flexible and structured logging capabilities, including context field extraction, multi-level\nlogging configuration, and multiple output options, making it ideal for a wide range of server-side applications.\n\n## Features\n\n* **Multi-Level Logging**: Supports standard log levels such as `Trace`, `Debug`, `Info`, `Warn`, `Error`, `Panic`, and\n  `Fatal`, suitable for debugging and monitoring in various scenarios.\n* **Structured Logging**: Records logs in a structured format with key fields like `trace_id` and `span_id`, making them\n  easy to parse and analyze by log aggregation systems.\n* **Context Integration**: Extracts additional information from `context.Context` (e.g., request ID, user ID) and\n  automatically attaches them to log entries.\n* **Tag-Based Logging**: Introduces a tag system to distinguish logs across different modules or business lines.\n* **Plugin Architecture**:\n    * **Appender**: Supports multiple output targets including console and file.\n    * **Layout**: Provides both plain text and JSON formatting for log output.\n    * **Logger**: Offers both synchronous and asynchronous loggers; asynchronous mode avoids blocking the main thread.\n* **Performance Optimizations**: Utilizes buffer management and event pooling to minimize memory allocation overhead.\n* **Dynamic Configuration Reload**: Supports runtime reloading of logging configurations from external files.\n* **Well-Tested**: All core modules are covered with unit tests to ensure stability and reliability.\n\n## Installation\n\n```bash\ngo get github.com/go-spring/log\n```\n\n## Quick Start\n\nHere's a simple example demonstrating how to use Go-Spring :: Log:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-spring/log\"\n)\n\nfunc main() {\n\t// Set a function to extract fields from context\n\tlog.FieldsFromContext = func(ctx context.Context) []log.Field {\n\t\treturn []log.Field{\n\t\t\tlog.String(\"trace_id\", \"0a882193682db71edd48044db54cae88\"),\n\t\t\tlog.String(\"span_id\", \"50ef0724418c0a66\"),\n\t\t}\n\t}\n\n\t// Load configuration file\n\terr := log.RefreshFile(\"log.xml\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tctx := context.Background()\n\n\t// Write logs\n\tlog.Infof(ctx, log.TagDef, \"This is an info message\")\n\tlog.Errorf(ctx, log.TagBiz, \"This is an error message\")\n}\n```\n\n## Configuration\n\nGo-Spring :: Log supports XML-based configuration for full control over logging behavior:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cConfiguration\u003e\n    \u003cProperties\u003e\n        \u003cProperty name=\"LayoutBufferSize\"\u003e100KB\u003c/Property\u003e\n    \u003c/Properties\u003e\n    \u003cAppenders\u003e\n        \u003cConsole name=\"console\"\u003e\n            \u003cJSONLayout bufferSize=\"${LayoutBufferSize}\"/\u003e\n        \u003c/Console\u003e\n    \u003c/Appenders\u003e\n    \u003cLoggers\u003e\n        \u003cRoot level=\"warn\"\u003e\n            \u003cAppenderRef ref=\"console\"/\u003e\n        \u003c/Root\u003e\n        \u003cLogger name=\"logger\" level=\"info\" tags=\"_com_request_*\"\u003e\n            \u003cAppenderRef ref=\"console\"/\u003e\n        \u003c/Logger\u003e\n    \u003c/Loggers\u003e\n\u003c/Configuration\u003e\n```\n\n## Plugin Development\n\nGo-Spring :: Log offers rich plugin interfaces for developers to easily implement custom `Appender`, `Layout`, and\n`Logger` components.\n\n## License\n\nGo-Spring :: Log is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-spring%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-spring%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-spring%2Flog/lists"}