This prompt is designed for a single, high-leverage task: classifying one raw log line into a standard severity level (DEBUG, INFO, WARN, ERROR, CRITICAL) and providing a structured, auditable justification. The ideal user is a DevOps engineer, SRE, or platform engineer who is building or maintaining an alerting pipeline. The core job-to-be-done is to normalize severity across heterogeneous services, filter noise before it pages an on-call engineer, or deterministically route log events to the correct downstream queue (e.g., a real-time alerting channel vs. a long-term analytics store). It assumes you have a single log line and, optionally, a service name or context tag, but not a full distributed trace or a multi-line log context window.
Prompt
Log Severity Classification and Triage Prompt Template

When to Use This Prompt
Understand the job-to-be-done, the ideal user, and the boundaries of this log severity classification prompt.
This prompt is not a replacement for a log aggregation UI, a full incident root cause analysis, or a multi-line trace correlation system. It will fail if you provide a truncated log line without enough signal, a message that requires understanding of prior log lines to interpret, or a log format the model has never seen. It is also not a security threat detector; while it can classify a log line as CRITICAL, it does not perform exploitability analysis. Use this prompt as a deterministic, auditable classification step before an alert fires, not as the alerting logic itself. The output is a structured JSON object with a severity level and a concise justification, which you can then use in your own routing rules.
Before you copy this prompt, confirm that your log pipeline can isolate single log lines with their service context. If your logs are multi-line (e.g., Java stack traces), you must pre-process them into a single-line summary or use a different prompt. If your severity definitions differ from the standard syslog-inspired levels, you must adapt the [CONSTRAINTS] section. The prompt is designed to be wired into a pre-production validation harness where you test it against a golden dataset of log lines with known severities before it ever touches a production pager. Start by running the prompt against your 100 most common log messages and manually reviewing any classification that differs from your current routing rules.
Use Case Fit
Where the Log Severity Classification and Triage Prompt works well and where it introduces operational risk.
Good Fit: Structured Log Pipelines
Use when: You have a stream of application logs in a known format (JSON, syslog, structured text) and need to assign a severity level before routing to alerting or storage tiers. The prompt excels at applying a consistent severity policy across high-volume, low-context log lines. Guardrail: Validate the output severity against a predefined enum (DEBUG, INFO, WARN, ERROR, CRITICAL) in the application harness before the log is routed.
Bad Fit: Ambiguous Business Logic Errors
Avoid when: The log message describes a business rule violation (e.g., 'Order total mismatch') where severity depends on financial impact, customer tier, or transaction state not present in the log line itself. The model will guess a severity based on linguistic patterns rather than business context. Guardrail: Route such logs to a separate queue for enrichment with transaction data before classification, or use a deterministic rules engine for known business error codes.
Required Inputs
Required: A single log line string, a severity taxonomy definition (e.g., CRITICAL means 'customer-facing outage'), and an output schema specifying the severity field and justification format. Optional but recommended: Service name, environment (prod/staging), and recent deployment markers to contextualize the log. Guardrail: If the log line is empty or unparseable, the prompt must return a default severity (INFO) with a flag for human review rather than hallucinating a classification.
Operational Risk: Severity Drift
Risk: Over time, the model may start classifying borderline WARN logs as ERROR or downgrading CRITICAL logs to ERROR due to subtle prompt drift or model version changes. This causes alert fatigue or missed incidents. Guardrail: Implement a regression test suite with 20-30 canonical log lines and their expected severities. Run this eval on every prompt or model version change and block deployment if classification accuracy drops below 95%.
Operational Risk: Justification Hallucination
Risk: The model may produce a plausible-sounding but factually incorrect justification for the severity, especially when the log line contains technical details the model misinterprets (e.g., mistaking a handled exception for an unhandled one). Guardrail: Treat the justification as a draft for human review in on-call workflows. For fully automated pipelines, suppress the justification field and rely only on the severity enum to avoid misleading downstream systems.
When to Use a Rules Engine Instead
Avoid when: You have a finite, well-known set of error codes or log patterns that map deterministically to severities (e.g., HTTP 5xx = ERROR, OOMKilled = CRITICAL). A rules engine is cheaper, faster, and has zero risk of misclassification. Use the prompt when: Log messages are free-form, the taxonomy is nuanced, or you need a justification for the severity decision that a human will review. Guardrail: Combine both: use a rules engine for known patterns and fall back to the prompt for unmatched log lines.
Copy-Ready Prompt Template
A production-ready prompt for classifying log severity with structured output, confidence scoring, and explicit handling of unparseable input.
This template is designed to be dropped directly into an application that needs to triage log lines before they hit an alerting pipeline, a logging dashboard, or an on-call rotation. It forces the model to reason from runtime impact definitions rather than mimicking the log level that may already appear in the text, which is the most common failure mode in naive log classification. The prompt includes a mandatory JSON output schema, a confidence score for downstream filtering, and an explicit fallback rule for unreadable or signal-free log lines so that your pipeline never receives a null classification.
textClassify the severity of the following application log line. Use only the standard severity levels: DEBUG, INFO, WARN, ERROR, CRITICAL. Base your classification strictly on the runtime impact described or implied by the log message, not on the log level it may already contain. A DEBUG message indicates internal diagnostic detail useful during development. INFO indicates normal operational events. WARN indicates a potential issue that does not yet cause failure. ERROR indicates a failure in a specific operation. CRITICAL indicates a service-wide outage or data loss. Service Context: [SERVICE_NAME] Log Line: [LOG_LINE] Return a JSON object with the following keys: - "severity": the classified level as a string. - "justification": a one-sentence explanation connecting the log content to the severity definition. - "confidence": a value from 0.0 to 1.0 indicating how certain the classification is. If the log line is completely unreadable, contains only a stack trace without a message, or provides no runtime impact signal, set severity to "INFO", justification to "Unparseable log line; no impact signal detected.", and confidence to 0.0.
To adapt this template, replace [SERVICE_NAME] with the actual service identifier (e.g., payment-gateway, user-auth) to give the model domain context that helps disambiguate impact. Replace [LOG_LINE] with the raw log text. If your logging pipeline already strips or enriches fields, inject those fields as additional context lines before the log line rather than modifying the severity definitions. The output schema should remain unchanged unless your downstream consumer requires additional fields such as component or suggested_action; if you add fields, add corresponding constraints and fallback values to prevent schema breaks. For high-throughput pipelines, consider adding a [MAX_TOKENS] constraint to the output and validating the JSON strictly before the classification enters any alerting rule.
Prompt Variables
Required and optional inputs for the Log Severity Classification and Triage prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check input quality before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[LOG_LINE] | The raw log message to classify, including any timestamp, level prefix, or structured metadata present in the original log | 2025-01-15T14:32:11.001Z ERROR [payment-service] Connection refused to database at db-primary.internal:5432 after 3 retries | Must be a non-empty string. Truncate to 4000 characters if longer. Do not pre-strip log level prefixes; the model needs them for context. |
[LOG_SOURCE] | Identifier for the originating service, host, or application component that produced the log line | payment-service / ip-10-0-1-42.ec2.internal | Must be a non-empty string. Use a consistent naming convention across all logs to enable correlation. Null allowed if source is unknown. |
[RUNTIME_CONTEXT] | Optional structured context about the system state when the log was emitted, such as deployment status, recent changes, or known incidents | Deployment v2.4.1 rolled out 5 minutes prior. Database connection pool size: 50. No active incident declared. | Null allowed. If provided, must be a string under 2000 characters. Avoid including raw PII or secrets. Validate that context is temporally relevant to the log timestamp. |
[SEVERITY_DEFINITIONS] | Custom severity level definitions for the organization, overriding default levels if provided | CRITICAL: Complete service outage or data loss. ERROR: Functionality broken for users but service still partially available. WARN: Degraded but functional. INFO: Normal operation record. DEBUG: Diagnostic detail. | Null allowed. If provided, must be a valid JSON object mapping level names to descriptions. Validate that at least one level is defined. Default to standard syslog levels if omitted. |
[OUTPUT_SCHEMA] | The expected JSON structure for the classification output, including field names and types | {"severity": "string", "confidence": "float between 0 and 1", "justification": "string", "requires_immediate_action": "boolean"} | Must be a valid JSON Schema or example object. Validate that required fields are present. The model will attempt to conform to this structure; schema mismatches are a common failure mode. |
[EXAMPLES] | Few-shot examples of log lines with correct severity classifications and justifications, used to calibrate the model's judgment | [{"log": "Connection timeout after 30s", "severity": "ERROR", "justification": "Dependency failure blocking user requests"}, {"log": "Cache miss for key user:12345", "severity": "DEBUG", "justification": "Normal cache behavior, no user impact"}] | Null allowed. If provided, must be a valid JSON array of objects with log, severity, and justification fields. Include at least one ambiguous example to prevent overconfidence. Validate that example severities are consistent with [SEVERITY_DEFINITIONS]. |
[CONSTRAINTS] | Behavioral rules for the classifier, such as handling of ambiguous logs, confidence thresholds, or escalation triggers | If confidence is below 0.7, set severity to WARN and note ambiguity in justification. Never classify a log as CRITICAL without evidence of user-facing outage or data loss. Prefer ERROR over CRITICAL when impact is uncertain. | Null allowed. If provided, must be a string under 1000 characters. Constraints should be testable: each rule must map to a pass/fail condition in the evaluation harness. Avoid vague constraints like 'be careful'. |
Implementation Harness Notes
Wire this prompt into a log processing pipeline with strict validation, retry logic, and a manual review fallback to prevent unvalidated LLM output from triggering alerts.
The classification prompt is a single component in a larger triage pipeline. It must be integrated into your existing log shipping infrastructure (e.g., Fluentd, Logstash, Vector) so that every incoming log event is enriched with a structured severity assessment before it reaches any alerting or routing system. The harness is responsible for extracting the service_name and log_line from the raw event, populating the prompt's [SERVICE_NAME] and [LOG_LINE] placeholders, and managing the lifecycle of the LLM call. The output of this harness is a structured JSON object that can be merged back into the log event's metadata, not a free-text response that requires downstream parsing.
Before the LLM's output is allowed to influence any operational decision, it must pass through a strict validation layer. The validator must confirm three things: the severity field is exactly one of the five allowed enum values (DEBUG, INFO, WARN, ERROR, CRITICAL), the confidence field is a float between 0.0 and 1.0, and the justification field is a non-empty string. If validation fails, the harness should retry the request once with the same prompt and a temperature of 0.0 to reduce output variance. If the retry also fails validation, the harness must default the severity to ERROR and route the entire event—including the raw LLM response and validation errors—to a manual review queue. Under no circumstances should an unvalidated LLM output page a human directly.
For auditability and debugging, every interaction with the model must be logged as structured metadata attached to the original log event. This includes the full prompt sent, the raw response received, the parsed and validated output, and the validation result (pass/fail). This design allows you to trace any misclassification back to the exact prompt and response pair, measure the retry rate and validation failure rate over time, and build a dataset of edge cases for future prompt improvement or fine-tuning. When selecting a model, prefer one with strong JSON mode and low variance at a temperature of 0.0. The harness should treat the LLM as an unreliable classifier and design its control flow accordingly, with the manual review queue acting as the ultimate safety net.
Expected Output Contract
Defines the exact JSON structure, field types, and validation rules for the log severity classification response. Use this contract to parse, validate, and integrate the model's output into an alerting pipeline.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
severity | enum: DEBUG, INFO, WARN, ERROR, CRITICAL | Must be one of the five allowed enum values. Reject any other string. | |
confidence | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. If confidence is below 0.7, route for human review. | |
justification | string | Must be a non-empty string (min 10 chars). Must reference at least one specific element from [LOG_LINE]. | |
impact_assessment | string | Must be one of: 'none', 'degraded', 'blocking', 'data_loss', 'security'. Reject unknown values. | |
affected_component | string or null | Must be a non-empty string if identifiable from [LOG_LINE], otherwise null. If null, confidence must be ≤ 0.8. | |
requires_immediate_action | boolean | Must be true if severity is CRITICAL or impact_assessment is 'blocking', 'data_loss', or 'security'. Validate consistency. | |
suggested_escalation | string or null | If present, must be one of the allowed escalation paths from [ESCALATION_POLICY]. If null, no escalation is suggested. |
Common Failure Modes
Log severity classification fails in predictable ways when the model encounters ambiguous signals, context-dependent severity, or format inconsistencies. These cards cover the most common failure modes and the guardrails that prevent them from reaching production.
Context-Blind Severity Inflation
What to watch: The model classifies a log line as CRITICAL or ERROR based on alarming keywords (e.g., 'failed', 'timeout', 'killed') without considering whether the failure is expected, retried successfully, or scoped to a non-critical path. A retryable connection timeout in a background job gets the same severity as a payment processing failure. Guardrail: Require the prompt to weigh runtime impact explicitly. Add a [SERVICE_CONTEXT] input that describes the component's criticality and expected failure modes. Test with log lines that contain scary keywords in benign contexts.
Inconsistent Severity Across Similar Logs
What to watch: Two log lines describing the same underlying error receive different severity labels because of minor wording differences, parameter values, or ordering. This breaks alerting thresholds and makes triage pipelines unreliable. Guardrail: Include few-shot examples that demonstrate consistent classification across parameterized variants of the same error. In eval, measure severity agreement across a set of semantically equivalent log lines with different surface forms. If variance exceeds 5%, the prompt needs more anchoring examples.
Justification-Classification Mismatch
What to watch: The model outputs a severity label but the justification describes a different severity level. For example, the justification says 'this indicates a complete service outage' but the label is WARN. This erodes trust in automated triage and causes missed alerts. Guardrail: Add a self-consistency check in the prompt template: after outputting the severity and justification, instruct the model to verify that the justification supports the chosen severity. In the harness, parse both fields and flag mismatches for human review before the classification enters an alerting pipeline.
Novel Error Pattern Misclassification
What to watch: The model encounters a log pattern it hasn't seen in few-shot examples and defaults to a middle severity (usually WARN) regardless of actual impact. This is especially dangerous for novel failure modes during incidents, where the model should err toward higher severity or flag uncertainty. Guardrail: Add an explicit 'uncertain' output option with a required escalation flag. Test the prompt against log lines from simulated novel failure modes. Measure the rate at which the model uses the uncertainty path instead of confidently misclassifying. Require human review for all UNCERTAIN classifications.
Format Drift Under High Log Volume
What to watch: When processing batches of logs, the model starts dropping fields, merging justifications, or outputting malformed JSON after the first few classifications. This is common when the prompt doesn't enforce per-line output discipline. Guardrail: Structure the prompt to process one log line per request rather than batching. If batching is required for latency, use a strict JSON array output schema with per-item validation. In the harness, validate that every log line in a batch receives a complete, well-formed classification object. Reject and retry partial outputs.
Silent Absorption of Unparseable Logs
What to watch: The model receives a malformed, truncated, or non-standard log line and attempts to classify it anyway, producing a confident but wrong severity. This hides ingestion problems and creates phantom alerts or missed signals. Guardrail: Add a pre-classification check: if the log line is unparseable, truncated, or missing required fields, output a special INVALID severity with the reason. Test with deliberately corrupted log lines. Measure that the model rejects unparseable input instead of hallucinating a classification. Route INVALID outputs to a dead-letter queue for pipeline debugging.
Evaluation Rubric
Use this rubric to test the Log Severity Classification prompt before integrating it into an alerting pipeline. Each row defines a pass/fail criterion, a concrete failure signal, and a test method that can be automated or run manually against a golden dataset.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Severity Level Accuracy | Output matches the expected severity label (DEBUG, INFO, WARN, ERROR, CRITICAL) for each log line in the golden dataset with >= 95% accuracy. | Model outputs WARN for a known CRITICAL log line (e.g., OOMKill) or DEBUG for a known ERROR. | Run against a labeled golden dataset of 100 log lines covering all severity levels and boundary cases. Measure exact match accuracy. |
Justification Grounding | The justification field references specific tokens or fields from the input log line (e.g., 'OutOfMemoryError', 'connection refused', 'status 200'). No hallucinated log content. | Justification mentions an error code or service name not present in the input log line, or provides a generic rationale with no log evidence. | Parse the justification field and check that all quoted strings or error codes exist in the input log line. Flag any justification with zero token overlap. |
Ambiguous Input Handling | For ambiguous log lines (e.g., 'Operation timed out after 30 seconds'), the model outputs a severity no higher than WARN and includes an uncertainty note in the justification. | Model classifies an ambiguous timeout as CRITICAL without acknowledging missing context (e.g., no user impact data, no retry status). | Test with a curated set of 20 ambiguous log lines where severity depends on external context. Check that output severity is WARN or lower and justification contains uncertainty language. |
Output Schema Compliance | Output is valid JSON matching the defined schema: { severity: string, justification: string, confidence: number }. Confidence is a float between 0.0 and 1.0. | Output is missing a required field, confidence is outside 0.0-1.0 range, or severity is not one of the five allowed enum values. | Validate output with a JSON schema validator. Check enum membership for severity and numeric range for confidence. Reject any output that fails parsing. |
Confidence Calibration | Confidence score correlates with classification difficulty: high confidence (>= 0.9) for unambiguous log lines, lower confidence (< 0.8) for ambiguous or context-dependent lines. | Model assigns 0.99 confidence to an ambiguous log line or 0.5 confidence to a clear CRITICAL error like 'disk full' on a database server. | Compute the mean confidence for the ambiguous test set and the unambiguous test set. The ambiguous mean should be at least 0.15 lower than the unambiguous mean. |
Boundary Case: INFO vs DEBUG | Log lines indicating successful operations with no diagnostic detail (e.g., 'Request completed in 45ms') are classified as INFO, not DEBUG. | Model classifies a standard access log line or successful health check as DEBUG, causing it to be filtered out of operational dashboards. | Test with 10 INFO-level log lines that contain timing or status but no error context. Verify none are classified as DEBUG. |
Boundary Case: ERROR vs CRITICAL | A service-specific error that does not cause user-facing downtime or data loss (e.g., 'Failed to send email notification') is classified as ERROR, not CRITICAL. | Model classifies a non-blocking background task failure as CRITICAL, triggering a page to on-call staff unnecessarily. | Test with 10 ERROR-level log lines where the failure is scoped to a non-critical subsystem. Verify none are classified as CRITICAL. |
Empty or Malformed Input Handling | For empty string, whitespace-only, or non-log input (e.g., a JSON object with no log message), the model returns a valid JSON output with severity 'INFO', confidence 0.0, and a justification stating the input was unclassifiable. | Model throws an error, returns invalid JSON, or hallucinates a severity based on no evidence. | Send empty string, ' ', and a random JSON object as inputs. Verify output schema compliance, confidence of 0.0, and a justification that indicates unclassifiable input. |
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 small set of representative log lines. Use a simple JSON output schema with only severity and justification fields. Test with a frontier model via API or playground before adding validation logic.
Prompt snippet:
codeClassify the log line into one of: DEBUG, INFO, WARN, ERROR, CRITICAL. Log: [LOG_LINE] Return JSON: {"severity": "...", "justification": "..."}
Watch for
- Model defaulting to WARN for ambiguous logs instead of asking for context
- Justifications that paraphrase the log rather than explaining runtime impact
- No handling of multi-line or truncated log messages

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