This playbook is for SRE, observability, and platform engineering teams who need AI-generated log entries to feed directly into logging pipelines, SIEM systems, or structured log aggregators. The prompt produces JSON log records where the severity field is locked to a controlled enum (DEBUG, INFO, WARN, ERROR, FATAL) and the assigned level is consistent with the content urgency described in the input. Use this when downstream systems reject or misroute log entries with non-standard severity strings, or when human operators write free-text severity that drifts from organizational logging standards.
Prompt
Log Level and Severity Enum Control Prompt Template

When to Use This Prompt
Determine if this prompt fits your observability pipeline and when to avoid it.
This prompt belongs in incident summarization pipelines, automated runbook logging, alert-to-log translation, and any workflow where structured observability data must survive automated validation before ingestion. It is not a general-purpose text generator. Do not use it when you need free-form narrative, when severity is unknown or intentionally omitted, or when the input content is too ambiguous to support a reliable severity mapping. The prompt assumes you have enough context—an alert payload, an incident note, a runbook step outcome—to justify a severity decision. If the input is a vague chat message, the model will guess, and guessing breaks downstream routing.
Before wiring this into a production pipeline, confirm that your log aggregator or SIEM expects the exact enum set defined in the prompt. If your organization uses custom levels like CRITICAL instead of FATAL, or TRACE instead of DEBUG, adapt the enum in the template before deployment. Also confirm that your validation layer rejects outputs where the severity field does not match the enum—never rely on the prompt alone. The next section provides the copy-ready template with placeholders for your input, context, and output schema.
Use Case Fit
Where this prompt works, where it fails, and what inputs it assumes for controlling log severity enums in structured outputs.
Good Fit: SRE and Observability Pipelines
Use when: you need every log record to carry a severity field drawn from a standard enum (DEBUG, INFO, WARN, ERROR, FATAL) before ingestion into Splunk, Datadog, or Elastic. Guardrail: pair this prompt with a post-generation validator that rejects any record containing a severity value outside the allowed set.
Bad Fit: Unstructured Natural Language Summaries
Avoid when: the task is to summarize an incident in prose without a structured log contract. This prompt forces enum-constrained fields and will degrade fluency if applied to free-text generation. Guardrail: use a separate summarization prompt for narrative output and reserve this template for structured log records only.
Required Inputs: Source Content and Severity Mapping Rules
What you must provide: raw log content or event descriptions, plus explicit mapping rules that define which content signals map to which severity level. Without mapping rules, the model defaults to inconsistent severity assignment. Guardrail: include a severity-assignment rubric in the prompt that defines triggers for ERROR (exception, data loss), WARN (degradation, retry), and INFO (normal operation).
Operational Risk: Severity Inflation and Deflation
What to watch: the model may inflate severity (marking routine events as ERROR) or deflate severity (marking critical failures as WARN) based on ambiguous content signals. This breaks alerting thresholds and on-call routing. Guardrail: add severity-appropriateness eval checks that compare model-assigned severity against human-labeled examples and flag systematic inflation or deflation trends.
Operational Risk: Enum Value Leakage
What to watch: the model may output near-match values like 'Warning', 'Error', 'Critical', or 'Fatal' instead of the exact enum members WARN, ERROR, FATAL. Downstream systems that perform exact string matching will silently drop or misroute these records. Guardrail: implement a strict post-generation validator that rejects any severity value not in the allowed set and triggers a retry or repair prompt.
Operational Risk: Context-Starved Severity Assignment
What to watch: when the input provides only a short log line without surrounding context, the model may default to INFO for safety, missing genuine ERROR conditions that require broader system state. Guardrail: include surrounding log context, stack traces, or service health metadata in the input window. When context is insufficient, instruct the model to output a confidence field alongside severity and escalate low-confidence assignments for human review.
Copy-Ready Prompt Template
A copy-ready prompt template for generating structured log entries with severity fields restricted to a standard enum and consistent content-to-level mapping.
This template instructs the model to produce a structured log record where the severity field is locked to a standard SRE enum: DEBUG, INFO, WARN, ERROR, or FATAL. It forces the model to map the urgency and impact described in the input text to the correct severity level, preventing vague or invented severity values that break downstream log aggregation and alerting pipelines. Use this template when you need every log entry to be immediately ingestible by tools like Splunk, Datadog, or the ELK stack without a normalization layer.
textYou are a structured log generation system. Your output must be a single JSON object representing a log entry. [CONTEXT] [EXAMPLES] [CONSTRAINTS] - The 'severity' field MUST be exactly one of the following strings: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'. No other values, abbreviations, or synonyms are permitted. - Map the input's urgency and impact to the correct severity level using these rules: - DEBUG: Verbose diagnostic information useful only for developers during active debugging. - INFO: Routine operational events that confirm the system is working as expected. - WARN: Unexpected events or potential problems that do not yet cause a service failure but require attention. - ERROR: A failure in a specific operation or component that requires immediate investigation but does not stop the entire system. - FATAL: A catastrophic failure that causes the entire application or a critical subsystem to shut down or become unavailable. - If the input does not contain enough information to confidently determine a severity level, default to 'INFO' and set the 'message' field to explicitly note the ambiguity. - The 'timestamp' field must be in ISO 8601 format with a UTC offset (e.g., '2023-10-26T14:30:00Z'). - The 'message' field must be a concise, factual summary of the event, not a question or a command. - The 'source' field must be a string identifying the originating component or service. [OUTPUT_SCHEMA] { "timestamp": "<ISO 8601 string>", "severity": "<DEBUG|INFO|WARN|ERROR|FATAL>", "message": "<string>", "source": "<string>", "traceId": "<string or null>" } [INPUT]
To adapt this template, replace the [INPUT] placeholder with the raw event description, log line, or error text. Populate [CONTEXT] with any system-wide rules, such as a service name to use in the source field or a specific trace ID format. Use [EXAMPLES] to provide few-shot demonstrations of ambiguous inputs mapped to the correct severity, which is the most effective way to calibrate the model's judgment. Before deploying, run the prompt through a validation harness that checks the output against the JSON Schema and confirms the severity field is a member of the allowed enum. For high-risk observability pipelines where a wrong severity level could suppress a critical alert, add a human review step for all ERROR and FATAL outputs before they are written to the production log stream.
Prompt Variables
Every placeholder the Log Level and Severity Enum Control prompt expects, why it matters, and how to validate it before sending.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[LOG_CONTENT] | The raw log message or event description that needs severity classification and structured formatting | Connection timeout after 30s to database primary at 10.0.1.5:5432 | Must be non-empty string. Validate length > 0 and < 8000 chars before sending. Truncate if needed with truncation marker appended. |
[TIMESTAMP] | The event occurrence time to embed in the structured log record | 2025-01-15T14:32:17.482Z | Must parse as valid ISO 8601 with timezone offset. Reject ambiguous formats like '01/15/2025'. If null, prompt instructs model to use current time marker. |
[SOURCE_COMPONENT] | Identifier for the system, service, or module that generated the log event | payment-gateway-v2 | Must match allowed component registry pattern: lowercase alphanumeric with hyphens, 3-64 chars. Validate against known component list if available. Reject empty or 'unknown'. |
[TRACE_ID] | Distributed trace identifier for correlating this log entry with upstream requests | a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6 | Must match hex string pattern, 32 chars. Validate format with regex ^[a-f0-9]{32}$. If null, prompt instructs model to generate a valid trace ID rather than omitting the field. |
[SEVERITY_ENUM] | The controlled vocabulary of allowed severity levels the model must choose from | ["DEBUG", "INFO", "WARN", "ERROR", "FATAL"] | Must be provided as a JSON array of strings. Validate array is non-empty and contains only uppercase alphabetic values. Do not allow synonyms like 'CRITICAL' or 'TRACE' unless explicitly added to the enum. |
[SEVERITY_MAPPING_RULES] | Guidance that maps content urgency signals to specific enum values to prevent severity inflation or deflation | FATAL: data loss or total outage; ERROR: operation failed but system continues; WARN: degraded but functional; INFO: normal operation milestone; DEBUG: diagnostic detail | Must be a non-empty string or structured object. Validate that each enum value in [SEVERITY_ENUM] has a corresponding mapping rule. Missing mappings cause inconsistent severity assignment. |
[REQUIRED_FIELDS] | List of fields that must appear in every output log record regardless of content | ["timestamp", "severity", "source", "message", "traceId"] | Must be a JSON array of field name strings. Validate array is non-empty. Each field name must match the output schema keys exactly. Post-generation: confirm every required field is present and non-null in the model response. |
[OUTPUT_SCHEMA] | The full JSON Schema or type contract the structured log record must satisfy | {"type": "object", "properties": {"severity": {"enum": ["DEBUG","INFO","WARN","ERROR","FATAL"]}}, "required": ["severity","timestamp","message"]} | Must be valid JSON Schema draft-07 or later. Validate schema parses without error before injection. Post-generation: run model output through schema validator and reject on validation failure with retry prompt. |
Implementation Harness Notes
How to wire the Log Level and Severity Enum Control prompt into a production observability pipeline with validation, retries, and safe defaults.
This prompt is designed to be called from an SRE or observability pipeline that already has the raw log content or incident context. The application layer should inject the [LOG_CONTENT] and [CONTEXT] placeholders before sending the request. The model is expected to return a JSON object with a severity field restricted to the standard enum: DEBUG, INFO, WARN, ERROR, FATAL. The application should never trust the raw model output directly. Instead, it must validate the severity field against the allowed enum set and reject or repair any output that does not conform. This is a classification and normalization task, not a generative one, so the harness should treat it as a structured extraction with a tight contract.
Wire the prompt into your application with a post-processing validator that checks three things: (1) the severity field is present and exactly matches one of the five allowed values, (2) the confidence field is a float between 0.0 and 1.0, and (3) the rationale string is non-empty and does not exceed a reasonable character limit (e.g., 500 characters). If validation fails, implement a retry loop with a maximum of two additional attempts. On each retry, append the validation error message to the prompt as additional [CONSTRAINTS] context so the model can self-correct. If all retries are exhausted, apply a safe fallback: default the severity to WARN and log the failure for human review. This prevents a single malformed output from blocking your log ingestion pipeline.
For observability, instrument every call with the model ID, prompt version, latency, token usage, and validation outcome. Emit a structured log event from the harness itself—ironically, using the same severity enum you are asking the model to produce. Tag validation failures as ERROR and successful retries as WARN. This creates a feedback loop where your own system's health is visible in the same schema you are enforcing. Avoid wiring this prompt directly into a synchronous user-facing flow; it belongs in an asynchronous processing step where a 2-second retry delay is acceptable. If you need sub-100ms responses, consider a smaller model or a cached classification layer instead of a general-purpose LLM.
Expected Output Contract
The exact JSON structure, field types, and validation rules the model must satisfy for a log entry with a severity enum field.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
timestamp | string (ISO 8601) | Must parse as valid ISO 8601 datetime with timezone offset. Reject ambiguous formats like MM/DD/YYYY. | |
severity | string (enum) | Must be exactly one of: DEBUG, INFO, WARN, ERROR, FATAL. Case-sensitive. Reject synonyms, abbreviations, or near-matches. | |
message | string | Non-empty string. Length between 1 and 4096 characters. Must summarize the log event in plain text. | |
source | string | Must identify the originating component or service. Non-empty. Match pattern: ^[a-z][a-z0-9-]*$ (lowercase kebab-case). | |
traceId | string (UUID v4) | If present, must be a valid UUID v4 string. Null allowed. Reject non-UUID or wrong-version UUIDs. | |
metadata | object | If present, must be a flat key-value object. All keys must be strings. Values must be string, number, or boolean. No nested objects or arrays. | |
errorCode | string | Required when severity is ERROR or FATAL. Must match pattern: ^[A-Z]{2,5}-\d{3,5}$. Reject if present for DEBUG or INFO. |
Common Failure Modes
What breaks first when using a prompt to enforce log severity enums, and how to guard against it before shipping.
Severity Inflation
What to watch: The model escalates WARN-level events to ERROR or FATAL when the input text contains emotionally charged language, even if the technical impact is low. Guardrail: Add a severity calibration rule in the prompt: 'Classify based on system impact, not user sentiment. A frustrated user report without an outage is WARN, not ERROR.'
Out-of-Vocabulary Severity
What to watch: The model invents a severity level like CRITICAL, SEVERE, or EMERGENCY instead of using the allowed enum [DEBUG, INFO, WARN, ERROR, FATAL]. Guardrail: Post-process the output with a strict enum validator. If the field value is not in the allowed set, reject the record and retry with a stronger constraint: 'You MUST choose exactly one of: DEBUG, INFO, WARN, ERROR, FATAL.'
Severity-Content Mismatch
What to watch: The model assigns INFO severity to a message describing a database connection failure, or FATAL to a routine health check. The enum is valid but semantically wrong. Guardrail: Include few-shot examples that pair log messages with their correct severity. Add an eval that samples outputs and checks whether severity aligns with a predefined mapping of keywords to expected levels.
Defaulting to Mid-Range Under Ambiguity
What to watch: When the input is ambiguous or lacks clear severity signals, the model defaults to WARN or INFO for everything, masking real issues. Guardrail: Add an explicit instruction: 'If severity cannot be determined from the log content, set it to INFO and set a needs_review flag to true.' This makes ambiguity visible rather than silently averaged.
Enum Drift Across Model Versions
What to watch: A prompt that reliably produces FATAL on one model version starts producing CRITICAL after a model upgrade, because the newer model has different internal severity associations. Guardrail: Pin a regression test suite with 20+ log messages and their expected severities. Run it against every model version change before promoting the prompt to production.
Batch Inconsistency in Structured Arrays
What to watch: When generating multiple log records in one response, the model applies severity rules inconsistently—identical error conditions get ERROR in record one and WARN in record three. Guardrail: Add a batch-consistency instruction: 'Apply the same severity rules uniformly across all records in this batch. If two log entries describe the same condition, they must receive the same severity.' Validate with a pairwise consistency check in evals.
Evaluation Rubric
How to test output quality before shipping. Run these checks against a golden dataset of at least 20 event descriptions with known-good severity assignments.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Severity Enum Membership | Every [SEVERITY] field value is one of: DEBUG, INFO, WARN, ERROR, FATAL | Any output containing TRACE, CRITICAL, UNKNOWN, or a lowercase variant | Parse each output record; assert [SEVERITY] in allowed set for all 20 golden inputs |
Severity-Content Mapping | [SEVERITY] matches the urgency level of [EVENT_DESCRIPTION] per the mapping rules in [SEVERITY_MAPPING_RULES] | A description containing 'disk full' or 'data loss' assigned INFO; a debug trace assigned ERROR | Human review of 20 output records; at least 90% agreement with known-good severity labels |
Output Schema Validity | Every output record parses as valid JSON matching [OUTPUT_SCHEMA] with all required fields present | Missing [TIMESTAMP] field; [SEVERITY] field is integer instead of string; extra undeclared fields | Run JSON Schema validator against each output record using the provided [OUTPUT_SCHEMA] |
Timestamp Format Compliance | Every [TIMESTAMP] field is ISO 8601 with timezone offset and matches the event time from [EVENT_DESCRIPTION] | Timestamp missing timezone; Unix epoch integer; relative time like '5 minutes ago' | Regex check for ISO 8601 pattern with timezone; parse and compare to expected event time |
No Severity Invention | Model never produces a severity level outside the defined enum, even for ambiguous or edge-case descriptions | Model outputs CRITICAL for a high-urgency event; model invents SEVERE or ALERT | Scan all outputs for out-of-vocabulary severity strings across the full golden dataset |
Consistent Severity for Equivalent Inputs | Two descriptions with identical urgency receive the same [SEVERITY] assignment | One 'connection timeout' event gets WARN, another nearly identical one gets ERROR | Run 5 pairs of semantically equivalent descriptions; assert identical severity output |
No Severity Defaulting Under Ambiguity | When [EVENT_DESCRIPTION] is genuinely ambiguous, model picks the closest severity rather than always defaulting to INFO or WARN | Every ambiguous description receives INFO; model never selects ERROR or FATAL for unclear cases | Include 3 intentionally ambiguous descriptions in golden set; verify distribution across severity levels, not all one value |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Start with the base prompt and a simple severity enum: [DEBUG, INFO, WARN, ERROR, FATAL]. Use a lightweight JSON schema validator in your test harness but skip strict timestamp or trace ID enforcement. Focus on getting the severity mapping right before adding operational fields.
Watch for
- The model inventing severity levels outside the enum (e.g.,
CRITICAL,TRACE,NOTICE) - Inconsistent mapping: a message body that sounds like
ERRORbut gets labeledWARN - Missing
timestampormessagefields when the prompt doesn't explicitly require them

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us