Load: Ask OpenCode to use the logging-patterns skill
Description
Java logging best practices with SLF4J, structured logging (JSON), and MDC for request tracing. Includes AI-friendly log formats optimized for OpenCode analysis.
Use Cases
- "Add logging to this service"
- "Debug this flow" (AI reads logs)
- "Setup structured logging"
- "Why is this request failing?" (analyze logs)
- "Add request tracing"
Key Insight: JSON for AI
JSON logs are better for AI/OpenCode analysis:
| Aspect | Text Logs | JSON Logs |
|---|---|---|
| Parsing | Regex interpretation | Direct field access |
| Tokens | Higher | Lower |
| Filtering | grep patterns | jq queries |
# AI can easily filter JSON cat app.log | jq 'select(.requestId == "abc123")'
Topics Covered
| Topic | Description |
|---|---|
| AI-Friendly Logging | JSON formats optimized for OpenCode |
| Spring Boot 3.4+ | Native structured logging support |
| Logstash Encoder | For Spring Boot < 3.4 |
| SLF4J/MDC | Request context, correlation IDs |
| Log Levels | When to use ERROR, WARN, INFO, DEBUG |
| What to Log | Business events, timing, flow steps |
| What NOT to Log | Passwords, PII, sensitive data |
Quick Setup (Spring Boot 3.4+)
logging: structured: format: console: logstash
No extra dependencies needed!
Related Skills
spring-boot-patterns- Spring configurationjpa-patterns- Database logging