Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/e-gov/cursor-prompts/application-logginggit clone --depth 1 https://github.com/e-gov/cursor-promptsWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.02320 | $0.02320 |
| Opus 5 | $0.01160 | $0.01160 |
| Sonnet 5 | $0.00464 | $0.00464 |
| Haiku 4.5 | $0.00232 | $0.00232 |
Grade A, and why
application-logging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 162 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Java Application Logging Standards (JSON/Logstash Format)
Context
- Apply this rule when implementing logging (Session, Activity, Debug, Error) in Java applications using the SLF4j API and configured with Logback and
net.logstash.logback.encoder.LogstashEncoder. - This rule complements, but does not replace,
mdc:rules/java-common/audit-logging.mdc, which covers specific security audit events. General principles here (like forbidden data) apply unless overridden by the audit rule. - For comprehensive security best practices, see
[security.mdc](mdc:rules/common/security.mdc). - The goal is consistent, informative, and secure application-level logging in a structured JSON format suitable for log aggregation systems (like ELK stack).
Requirements
- Logging Facade: Use the SLF4j API for all logging statements.
- Encoding: Logback configuration ensures UTF-8 (default for LogstashEncoder).
- Language: Use English for log messages and field names where possible. The log message itself goes into the
messagefield in the JSON output. - User Input Handling:
- Encode non-printable characters and line separators in user-provided data if they are included directly in log messages. LogstashEncoder generally handles JSON encoding for standard fields.
- Be mindful of log injection if constructing message strings dynamically with user input. Use parameterized logging (
log.info("User {} action", userInput)).
- Correlation ID: Implement and consistently use a unique correlation ID via MDC's
requestIdkey. This MUST be populated for all logs within a request scope, typically set up in a web filter or interceptor. - Log Levels, Categories & Locations:
- Request Boundaries (Filter/Interceptor Recommended):
- Log request start at
INFOlevel, includingrequestId,clientIp, HTTP method, path. - Log request completion at
INFOlevel, includingrequestId, status code, duration.
- Log request start at
- Controllers:
- Log validation errors at
WARNlevel. - (Optional) Log entry to complex controller methods at
DEBUGlevel. - Log unhandled exceptions caught by
@ControllerAdviceatERRORlevel.
- Log validation errors at
- Services:
- Log
INFO(Activity Log) for significant business events (e.g., object creation/update, state transitions) and interactions with external systems. Include relevant context (e.g.,objectId,eventTypevia MDC). - Log
INFO(Session Log) for authentication/authorization events (logins, logouts, permission changes - excluding forbidden data). - Log
WARNfor handled business exceptions or known error conditions. - Log
ERRORfor unexpected exceptions during service execution. - Use
DEBUGjudiciously for detailed internal logic flow tracing in complex methods.
- Log
- Other Components: Limit logging in repositories/DAOs primarily to
ERRORfor specific data access failures. Use framework-level SQL logging if needed.
- Request Boundaries (Filter/Interceptor Recommended):
- Contextual Fields (via MDC): Populate MDC for relevant context. The configured LogstashEncoder automatically includes standard fields. Ensure the following are consistently populated at the appropriate layers:
requestId: (Mandatory) Unique ID for the request/transaction. Typically set in a filter/interceptor.sessionId: Session identifier, if available. Set in filter/interceptor.userId: Identifier of the acting user (WHO). Set in filter/interceptor after authentication.clientIp: Source IP address of the request (WHENCE). Set in filter/interceptor.applicationName: Identifier for the application/service (WHERE). Set globally or via MDC.- (Recommended) Consider adding these fields via MDC within services/controllers for richer context where relevant:
eventType: Standardized identifier for the business event (e.g.,USER_LOGIN,ORDER_CREATED).objectId: Identifier of the primary business object involved.eventResult: Outcome of a specific operation (SUCCESS,FAILURE,VALIDATION_ERROR).traceId/spanId: Distributed tracing identifiers when OpenTelemetry is enabled (helps correlate logs with traces).- Note: If using OpenTelemetry, prefer automatic MDC population via OTel instrumentation or a Logback OTel appender; otherwise, set these via a web filter/interceptor so they are included in logs.
- Standard JSON Fields: Be aware that LogstashEncoder automatically adds fields like:
@timestamp: Event timestamp (WHEN). ISO 8601 format.@version: Logstash schema version (usually 1).message: The formatted log message string.logger_name: The name of the SLF4j logger.thread_name: Name of the logging thread.level: Log level (e.g., "INFO").level_value: Numeric log level.stack_trace: Included for logs with exceptions at ERROR level.
- Forbidden Data: Strictly avoid logging data listed in the "Forbidden Data" section below, whether in the
messagefield or any custom MDC fields. - Log Format: The format is JSON, generated by
net.logstash.logback.encoder.LogstashEncoderbased on the Logback configuration (logback-spring.xml). No specificPatternLayoutis needed for the main application logs. - Documentation: Document service-specific log events, important custom MDC fields used, and any deviations from this standard.
- Background Process Logging: Log all background process activities (scheduled jobs, batch processing, data synchronization) using appropriate log levels (INFO for normal operation, WARN for issues, ERROR for failures).
- Success/Failure Logging: Log both successful and failed operations using appropriate log levels (INFO for success, WARN for handled errors, ERROR for unexpected failures).
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 162 lines · 2,320 tokens per session scan A 434ebf52ba3a
application-logging is a cursor rule published in the GitHub repository e-gov/cursor-prompts (34 stars, last pushed 4mo ago), licensed MIT. It adds 2,320 tokens to every session, about $0.0116 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.