structured-logging
π―Skillfrom bitsoex/bitso-java
Implements RFC-34 structured logging standards for Java services, enabling JSON-formatted logs with required fields and contextual metadata.
Installation
npx skills add https://github.com/bitsoex/bitso-java --skill structured-loggingSkill Details
>
Overview
# Structured Logging
RFC-34 compliant structured logging standards for Java services.
When to use this skill
- Implementing logging in new Java services
- Converting unstructured logs to structured format
- Reviewing logging practices
- Configuring Logback for JSON output
- Adding business context to logs
Skill Contents
Sections
- [When to use this skill](#when-to-use-this-skill) (L24-L31)
- [Quick Start](#quick-start) (L51-L71)
- [Required Fields](#required-fields) (L72-L86)
- [Best Practices](#best-practices) (L87-L105)
- [References](#references) (L106-L111)
- [Related Rules](#related-rules) (L112-L115)
- [Related Skills](#related-skills) (L116-L121)
Available Resources
π references/ - Detailed documentation
- [logging standards](references/logging-standards.md)
---
Quick Start
1. Add Dependencies
```groovy
implementation 'org.springframework.boot:spring-boot-starter-logging'
implementation 'net.logstash.logback:logstash-logback-encoder:${latest_version}'
```
2. Use Structured Arguments
```java
import static net.logstash.logback.argument.StructuredArguments.kv;
log.info("Transaction processed",
kv("transaction_id", txn.getId()),
kv("user_id", user.getId()));
```
This produces JSON with separate fields for transaction_id and user_id.
Required Fields
All logs must include these fields:
| Field | Description |
|-------|-------------|
| @timestamp | Log timestamp |
| message | Log message text |
| logger | Logger name |
| thread_name | Thread name |
| level | Log level (INFO, WARN, ERROR, etc.) |
| dd.service | Service name |
| dd.env | Environment |
| dd.version | Service version |
Best Practices
- Add business identifiers (IDs) as separate fields instead of embedding in messages
- Keep log message text clear and concise
- Use appropriate log levels consistently
- Include enough context to understand the event without additional queries
- Use snake_case for field names
- For logs containing objects, properly structure them rather than using
toString()
Example
```java
// β Good - structured fields
log.info("Order created", kv("order_id", orderId), kv("user_id", userId), kv("amount", amount));
// β Bad - embedded in message
log.info("Order {} created for user {} with amount {}", orderId, userId, amount);
```
References
| Reference | Description |
|-----------|-------------|
| [references/logging-standards.md](references/logging-standards.md) | Complete RFC-34 implementation guide |
Related Rules
.cursor/rules/java-structured-logs.mdc- Full logging standards
Related Skills
| Skill | Purpose |
|-------|---------|
| [java-standards](../java-standards/SKILL.md) | General Java standards |
| [java-testing](../java-testing/SKILL.md) | Testing log output |
More from this repository10
Configures and manages MCP (Model Context Protocol) server settings across multiple IDEs for seamless integration and development workflow.
Standardizes REST API development in Java Spring by providing authentication, OpenAPI documentation, and RFC-37 service guidelines.
Streamlines PostgreSQL database integration in Java projects by configuring jOOQ code generation, Flyway migrations, and version compatibility.
doc-sync skill from bitsoex/bitso-java
Manages and standardizes Git hooks across repositories, ensuring consistent code quality checks and team-wide hook compliance automatically.
Integrates SonarQube with MCP to enable natural language querying of Java code quality issues, analysis, and quality gate checks.
Centralizes and standardizes Gradle build configurations for Java projects, managing dependencies, version catalogs, and multi-module setups efficiently.
Automates resolution of Dependabot security vulnerabilities in Java/Gradle projects using severity-based processing and dependency verification.
Configures and generates JaCoCo code coverage reports for Java/Gradle projects, enabling comprehensive testing analysis and quality metrics.
Upgrades Gradle projects from version 8.x to 9.x, ensuring plugin compatibility and supporting Java 25 migration.