slf4j
SLF4J - Simple Logging Facade for Java. Standard logging API that abstracts underlying implementation (Logback, Log4j2). Provides parameterized logging and MDC support. USE WHEN: user mentions "slf4j", "java logging api", "parameterized logging", asks about "how to log in Java", "logger facade", "MDC in java", "logging best practices java" DO NOT USE FOR: Logback configuration - use `logback` instead, Log4j2 configuration - use Log4j2 skill, Node.js logging - use `winston` or `pino` instead, Python logging - use `python-logging` instead
What this skill does
# SLF4J - Quick Reference
## When to Use This Skill
- Standard logging API for Java
- Integration with Logback, Log4j2
- Java logging best practices
> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `slf4j` for comprehensive documentation.
## Essential Patterns
### Logger Declaration
```java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserService {
private static final Logger log = LoggerFactory.getLogger(UserService.class);
// Or with Lombok
// @Slf4j on class
}
```
### Logging Levels
```java
log.trace("Detailed debug info: {}", details);
log.debug("Debug info for development");
log.info("Normal operation: user {} logged in", userId);
log.warn("Potential problem: {} retries remaining", retries);
log.error("Error occurred: {}", message, exception);
```
### Parameterized Logging
```java
// Good - lazy evaluation
log.debug("Processing order {} for user {}", orderId, userId);
// Avoid - always evaluates
log.debug("Processing order " + orderId + " for user " + userId);
// Multiple parameters
log.info("User {} performed {} on resource {}", userId, action, resourceId);
```
### Exception Logging
```java
try {
processOrder(order);
} catch (OrderException e) {
// Exception is always last parameter
log.error("Failed to process order {}: {}", order.getId(), e.getMessage(), e);
}
```
### MDC (Mapped Diagnostic Context)
```java
import org.slf4j.MDC;
// Set context
MDC.put("requestId", requestId);
MDC.put("userId", userId);
try {
// All logs in this scope will include requestId and userId
log.info("Processing request");
} finally {
MDC.clear();
}
```
### Conditional Logging
```java
if (log.isDebugEnabled()) {
log.debug("Expensive computation result: {}", expensiveMethod());
}
// Better with lambdas (SLF4J 2.0+)
log.atDebug().log(() -> "Result: " + expensiveMethod());
```
### Fluent API (SLF4J 2.0+)
```java
log.atInfo()
.addKeyValue("orderId", orderId)
.addKeyValue("amount", amount)
.log("Order processed successfully");
```
## When NOT to Use This Skill
- **Logging framework configuration**: Use `logback` or Log4j2 skills for XML/config
- **Performance tuning**: Configuration-level optimization is in implementation skills
- **Transport/appender setup**: That's implementation-specific (Logback/Log4j2)
- **Non-Java projects**: Use language-appropriate logging APIs
- **Direct implementation usage**: Always code to SLF4J API, not Logback/Log4j2 directly
## Anti-Patterns
| Anti-Pattern | Why It's Bad | Solution |
|--------------|--------------|----------|
| String concatenation in logs | Always evaluated, performance hit | Use parameterized logging: `log.info("User {}", id)` |
| Logging without level check for expensive ops | Wastes CPU even when disabled | Use `if (log.isDebugEnabled())` before expensive calls |
| Catching exceptions without logging | Silent failures, hard to debug | Always log with `log.error("msg", exception)` |
| Not using MDC for request context | Loses correlation across logs | Use `MDC.put()` with try-finally |
| Using wrong log level | Too much noise or missing issues | Follow conventions: ERROR=requires action, WARN=potential issue |
| Logging sensitive data | Security/compliance violation | Mask PII, passwords, tokens before logging |
## Quick Troubleshooting
| Issue | Cause | Solution |
|-------|-------|----------|
| NoClassDefFoundError: StaticLoggerBinder | No SLF4J implementation on classpath | Add Logback or Log4j2 dependency |
| Multiple bindings warning | Multiple SLF4J implementations | Keep only one: Logback OR Log4j2 |
| Logs not appearing | Wrong log level | Check implementation config (logback.xml) |
| Parameters not replaced | Wrong placeholder syntax | Use `{}` not `%s` or other formats |
| MDC values empty | MDC cleared or wrong thread | Ensure MDC.put() before logging, clear in finally |
| Exception stack trace missing | Exception not last parameter | Put exception as last param: `log.error("msg", e)` |
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.