1---2name: li-lance-android-seraphim-framework-golang-logging3description: Golang Logging Standards4---56# Golang Logging Standards78## **Priority: P1 (STANDARD)**910## Principles1112- **Structured Logging**: Use JSON or structured text. Readable by machines and humans.13- **Leveled Logging**: Debug, Info, Warn, Error.14- **Contextual**: Include correlation IDs (TraceID, RequestID) in logs.15- **No `log.Fatal`**: Avoid terminating app inside libraries. Return error instead. Only `main`16 should exit.1718## Libraries1920- **`log/slog` (Recommended)**: Stdlib since Go 1.21. Fast, structured, zero-dep.21- **Zap (`uber-go/zap`)**: High performance, good if pre-1.21 or extreme throughput needed.22- **Zerolog**: Zero allocation, fast JSON logger.2324## Workflow: Set Up Structured Logging with slog25261. Create a JSON handler at startup in `main()`272. Optionally wrap in middleware to inject request-scoped attributes283. Use `slog.With()` to add correlation IDs per request294. Pass logger via context or dependency injection3031See [slog setup and usage examples](references/slog-patterns.md)3233## References3435- [Slog Patterns](references/slog-patterns.md)3637## Anti-Patterns3839- **No fmt.Println in production**: Use slog or zap for structured, leveled logging.40- **No log.Fatal in libraries**: Return errors; only main() should call os.Exit.41- **No unstructured log strings**: Include correlation IDs and structured fields via slog.Attr.4243---44> Source: [li-lance/android-seraphim-framework](https://github.com/li-lance/android-seraphim-framework) — distributed by [TomeVault](https://tomevault.io).45<!-- tomevault:4.0:skill_md:2026-06-16 -->
Run npx skillmds@latest add tomevault-io/li-lance-android-seraphim-framework-golang-logging in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Golang Logging Standards It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.