logging

Enforce SLF4J logging conventions with parameterized placeholders and safe log levels.

10|1|Updated Mar 8, 2026
One-click install
npx skills add https://github.com/andresdiegolanda/design-first-ai --skill logging-andresdiegolanda
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging
Source: https://github.com/andresdiegolanda/design-first-ai/tree/main/context/skills/logging
Command: npx skills add https://github.com/andresdiegolanda/design-first-ai --skill logging-andresdiegolanda

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Logging is often inconsistent, noisy, or unsafe, exposing personally identifiable information (PII) or using incorrect log levels that make diagnosis and monitoring difficult. This Skill provides clear, actionable rules so engineers produce meaningful, non-sensitive log statements that support debugging and observability without leaking private data.

Core Features & Use Cases

  • Consistent logging conventions using SLF4J and parameterized placeholders to avoid string concatenation.
  • Clear mapping of intent to level: DEBUG for entry/exit, INFO for business events, WARN for recoverable issues, ERROR at exception boundaries.
  • Safety rules preventing PII and full request/response bodies from being logged, and guidance for where to log stack traces.
  • Use cases: adding new service logs, performing log-focused code reviews, and auditing existing log coverage.

Quick Start

When adding a service method, insert a DEBUG entry log with parameterized placeholders and an INFO business event for resource creation, and never include PII or full request/response bodies.

Frequently Asked Questions about logging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent PII from appearing in Java application logs?

To prevent PII in Java logs, avoid logging personally identifiable information and full request or response bodies. Apply safety rules during code reviews to ensure log statements exclude sensitive data while maintaining debugging and observability capabilities.

What are the correct log levels for Java service methods?

Correct log levels map intent to severity: DEBUG for entry and exit points, INFO for business events, WARN for recoverable issues, and ERROR at exception boundaries. This mapping ensures logs remain meaningful and support effective monitoring.

How do I use SLF4J parameterized placeholders for logging?

Use SLF4J LoggerFactory with parameterized placeholders instead of string concatenation to create consistent log statements. This approach improves performance and ensures safe, structured logging across Java services, handlers, and libraries.

What is the best way to review logging consistency in Java code?

The best way to review logging consistency is to enforce rules during code reviews: verify correct SLF4J parameterized usage, validate appropriate log levels, and confirm no PII or full request bodies are logged. This ensures safe, meaningful logs.

Does this logging approach work for Java libraries and handlers?

Yes, this logging approach applies to Java services, handlers, and libraries. It enforces consistent, safe log statements using SLF4J LoggerFactory and parameterized placeholders across the codebase, ensuring observability without leaking private data.

When should I log stack traces in Java applications?

Log stack traces at exception boundaries using the ERROR level. This ensures severe issues are captured for diagnosis while preventing noisy logs from lower-level recoverable issues, maintaining clear observability and consistent logging conventions.