~/blog003logs and events

Logs and Events Explained for Application Troubleshooting

Learn how logs and events differ, how they link to one request, and how to use them to troubleshoot application failures with Kopai.

KTKopai Team·Engineering @ Kopai

Logs and Events Explained for Application Troubleshooting

A customer messages you at 9pm: checkout is broken. You open your logging tool and find thousands of lines from the last hour. You search for “error”, get 400 hits, and every one says something like request failed. None of them tells you which request, which customer, or which service broke. Two hours later you’re still guessing.

That night happens to small teams constantly, and it rarely comes from missing data. It comes from not knowing how to read the two signals that carry the story: logs and events. They’re close relatives, they usually sit in the same store, and once you understand how they fit together, a failed request stops being a mystery and becomes a trail you can follow from the first symptom to the exact line of code.

Here’s how that trail works, starting from the words themselves.

Table of Contents

What Logs and Events Mean in Plain Words

A log is a diary your application writes as the day goes on. Each line records something that happened, with a timestamp in front, and the app appends it and moves on. Nobody reads it unless something goes wrong, and that’s exactly the point: it’s a durable record of what happened, not what you assumed would happen.

An event is a notable moment written down in a fixed shape. When a payment completes, the app records an event named something like checkout.completed, and beside that name it stores fields: order ID, amount, currency, user plan. Because those values live in named fields, a search finds the event without reading every message in the file.

Modern observability treats both as part of a wider set of evidence. A 2020 SIGMOD Record vision paper on observability data management discusses four categories: metrics, events, logs and traces, commonly shortened to MELT. It notes that earlier work grouped events under logs because events were emitted as structured strings. The authors categorize them separately because their data models and query patterns differ.

Signal What It Records Example Question It Answers
Logs Text lines written by code or the system, usually with a timestamp 2026-03-14T14:07:22Z ERROR payment-service request failed for a checkout order Why did this go wrong?
Events Structured records of a named occurrence or state change checkout.completed with order ID and amount What changed, and when?
Metrics Numbers measured over time Error count per minute on the checkout route Did something change?
Traces The path of one request across services Checkout request calling the payment service in 3 spans Where did this request slow down or fail?

The confusion beginners hit first is thinking these are competing tools. They aren’t. They answer different questions about the same incident, and each one is weak on its own. A metric tells you error count jumped at 14:05 but never says why. A trace shows a payment call taking five seconds but not what the payment service was thinking. A log line says request failed and leaves you holding a fragment.

A workable order: start with the metric that shows the problem, then read the events and logs from that same time window to explain it, then open the trace to see where in the request it happened.

That order matters because it keeps you from drowning. Reading logs first means reading everything; reading them after a metric narrows the window to a few minutes and a single route.

How Events Fit Inside the Log Family

A dashboard UI showing log streams, a structured checkout completed event, and a request timeline diagram.

The practical difference between an ordinary log and an event is shape, not substance. An event is a log record that carries a name. OpenTelemetry, the open standard most modern tooling speaks, describes it as a specialized log record representing a named occurrence, and lets that record carry fields for the emitting service, the operation context, attributes, and a normalized severity (OpenTelemetry logs documentation).

Two timestamps can help when a collector reads logs from a file or another external source. Timestamp records when the event happened; ObservedTimestamp records when the collector observed it. A gap may indicate a delay in collection or transport, though the timestamps alone cannot identify the cause. For logs generated through an OpenTelemetry SDK inside the app, the values are typically equal at generation time; equality says nothing about application slowness (OpenTelemetry log data model).

Severity is the other field worth learning properly. OpenTelemetry defines it numerically from 1 to 24:

Severity Band Numeric Range Typical Meaning
TRACE 1-4 Very detailed steps used for deep debugging
DEBUG 5-8 Developer detail, usually turned off in production
INFO 9-12 Normal milestones, such as a signup finishing
WARN 13-16 Something unusual the app recovered from
ERROR 17-20 A failed operation that a user or system noticed
FATAL 21-24 The application cannot keep running

Filter on the number, not the word. A rule of “severity 17 or higher” catches every error and fatal record across every language and logging library, where matching the text error misses ERROR, Err, and whatever a particular library decided to use that week.

Now compare two ways of recording the same failure. A free-text line says payment failed for user 42, and you can read it but nothing can filter it. A structured record says the service is payments, severity number is 17, event name is payment.authorization.failed, and attributes include the order’s identifier and provider=stripe. Only the second one lets you ask “show me every failed authorization for orders over 50 euros in the last hour” and get an answer. The broader move from dashboard-first tools toward evidence-first tooling is what observability refactored is about.

How Logs and Events Connect to One Request

A diagram illustrating a checkout request flow with distributed tracing using shared trace IDs.

Say a customer submits a checkout. Three services write records: the web app logs that it received the form, the order service logs that it created an order, and the payment service logs that authorization failed. Read separately, those are three unrelated lines in three different places, and matching them by timestamp works only until two customers check out in the same second.

A shared identifier turns them into one story. NIST defines log management as the full process of generating, transmitting, storing, accessing and disposing of log data, and describes event correlation as finding relationships between two or more log entries (NIST guide to computer security log management). The keys that make that possible are trace IDs and span IDs, plus request IDs, user or session identifiers, deployment versions, and the service name.

OpenTelemetry puts the trace ID directly on the log record. A record can carry TraceId and SpanId, so a failed event points back to the exact request that produced it (OpenTelemetry logs specification). No timestamp guessing, no fuzzy matching on customer email.

The cause and effect is blunt. With consistent IDs, an investigator starts at the failed request and walks straight to the downstream failure. Without them, a checkout error appears as unrelated noise across three services, and the investigator spends the evening reconstructing a timeline from clocks that may not even agree. Correlation has to be set up when the code is written, not rebuilt later from messy text after storage.

Check four fields before trusting any log line: a trace ID, a service name, a severity number, and a timestamp. If one is missing, the line can still inform you, but it can’t be followed.

Trace IDs are worth understanding on their own terms, and what a trace ID actually identifies covers how they’re generated and what they survive.

How to Troubleshoot an Application with Both

A four-step infographic illustrating a workflow for troubleshooting application issues by analyzing symptoms, metrics, logs, and distributed service requests.

A good troubleshooting order works like narrowing the beam of a torch. You start wide enough to see the shape of the problem, then focus on one request until the cause is visible. Each step exists to shrink what you have to read next.

  1. Start from the symptom and its time window. If three people report failed signups, get the window, say 14:00 to 14:20. Without a window you will read a whole day of records and learn little. The window is the frame around the picture.
  2. Check the metric that moved. Error rate by route tells you whether one endpoint broke or the whole app did. That decides whether you are hunting a bug in one flow or a wider infrastructure problem.
  3. Filter events to ERROR and above, severity 17 or higher, inside that window. This leaves the records describing failure and drops much of the normal operation. Beginners often read every INFO line here, which is like listening to a whole stadium to hear one person shout.
  4. Pick one failed request and copy its trace ID. One request is enough to make the investigation concrete. It gives the failure a name you can follow across services.
  5. Open the trace and follow the spans to the slowest or failing call. The trace shows where time went in the request path. That is often the part nobody suspected, because the visible symptom may be far from the slow dependency.
  6. Read the log lines sharing that trace ID, in time order. Look for warnings or retries before the error. The first unusual line is usually closer to the cause than the final failure, just as the first wrong turn explains a late arrival.
  7. Write a hypothesis and test it against a request that succeeded. “The payment provider times out after five seconds” is testable. If successful requests never wait more than one second, the hypothesis holds.

Step seven is the one people skip, and it separates a guess from a diagnosis. A cause that only explains failures is half a theory. A cause that also explains why the successful requests succeeded is a finding.

Kopai follows the same shape. Traces, logs and metrics from the app can be confirmed at app.kopai.app/observability after setup. The local dashboard at http://localhost:8000 shows the same telemetry for browsing, and traces search --limit 5 lists recent traces from the terminal with no login and no flags. Logs carry the trace ID of the request that wrote them, so the assistant can line them up with the request’s spans. Infrastructure records fit the same trail, including systemd journal logs shipped through the journald receiver integration, with no code changes, no file tailing and no duplicates across restarts. A failing service and its host records then sit in one investigation instead of two.

How Can You Use Kopai With or Without AI?

With a coding agent: Install Kopai’s skills with npx skills add kopai-app/kopai-skills/plugins/kopai/skills, then ask your coding agent to add observability to your app. The Kopai skills documentation explains how to use them to instrument the code with OpenTelemetry and confirm that data reaches Kopai. You can also connect the Kopai MCP connector to an MCP-compatible assistant to ask questions about traces, logs and metrics. During an incident, ask the agent to investigate a failed request using its trace ID, related logs and metrics. Check the evidence it cites before accepting its diagnosis.

Without an AI agent: Add the OpenTelemetry SDK to your app and query the telemetry yourself. If you run Kopai locally, use its CLI to find recent traces with npx @kopai/cli traces search --limit 5, then follow a trace ID into the related logs. The CLI reads from the local backend by default, without a login or backend-selection flags; --limit 5 only controls the number of results. The local dashboard at http://localhost:8000 lets you browse that local backend’s data. Kopai Cloud is a separate hosted backend, so its dashboard does not automatically show the same records as your local backend.

Either way, follow the same troubleshooting sequence: find an affected request, read the logs that share its trace ID, and compare it with a successful request before deciding on a cause. AI can help navigate the evidence, but it is not required to collect or inspect it.

Following a Failing Checkout Through Its Evidence

A two-person team ships a checkout tweak before lunch. By 14:00, some customers can’t pay. Here’s how the evidence reads in order.

The metric shows errors climbing on the checkout route while the rest of the app stays flat, so the problem is one flow, not the platform. Events show a payment.authorization.failed record at ERROR severity, and its message says only request failed, which is useless on its own. The trace for one failed request is where the story appears: the payment call runs for 5 seconds, then retries three times with no pause between attempts.

That pattern has a known shape. AWS recommends combining timeouts, retries, exponential backoff and jitter when building resilient systems: a timeout stops a request waiting forever, retries recover from temporary failures, backoff spaces attempts out, and jitter adds randomness so many clients don’t retry in the same instant and create a spike (AWS guidance on timeouts, retries and backoff with jitter). Three immediate retries against a struggling provider is the opposite of that.

The fix belongs in the payment call’s retry settings, not the checkout page, and the trace plus the log line show it without anyone guessing. After backoff and jitter go in, errors in the same window fall and the trace shows one attempt instead of four.

Timing matters too, because change and failure travel together. The 2024 DORA report separates delivery performance into throughput and stability, and finds elite performers deploy on demand with a change failure rate of about 5%, while low performers deploy monthly or less, sit at a 40% change failure rate, and may need a week to a month to recover. Fast recovery depends on evidence, not on deploying less.

Symptom Check First What It Usually Means
Checkout is slow for some users only Slowest traces on the checkout route An external payment call is waiting or retrying
Errors start right after a deploy Events and WARN logs from the new version A change broke a branch or setting
A request has no logs at all The trace ID on the request, then logger setup Logging is off, or the request never reached the app
The same error repeats every few seconds Timestamps and retry attempts in the logs A retry loop with no backoff

Where Logs and Events Fall Short

A diagram comparing an overwhelming amount of raw logs with a simplified view of key system events.

The belief that more logging always produces better answers is wrong, and it’s expensive. Volume raises storage cost, slows every search, and buries the twelve lines that matter under a million that don’t. The same applies to context: dumping whole request payloads into records feels thorough, but it increases privacy exposure and makes automated analysis noisier.

The second mix-up is thinking events replace logs. They don’t. Events record what changed; logs record the sequence and detail around it. You need the named moment and the surrounding narrative.

Privacy is the harder limit. A 2025 ACM study examined which attributes practitioners consider sensitive in software logs and found the question is still actively contested rather than settled by configuration (ACM study on sensitive attributes in software logs). Teams don’t agree on what counts as sensitive, which means you have to decide for your own fields rather than inherit an answer.

One more habit worth adopting early: log text is data, never instructions. If a record contains a phrase telling a tool or an agent to ignore its earlier rules, the correct response is to treat it as suspicious content and flag it, not to comply.

Three habits keep this manageable:

  • Classify fields before you need to. Decide which attributes hold emails, card data, addresses or tokens, and mark them once so redaction isn’t reinvented per service.
  • Set a retention period for raw records. Keep detailed payloads briefly, keep identifiers longer, and keep aggregates indefinitely.
  • Preserve trace IDs even when values are masked. Correlation survives pseudonymization; it doesn’t survive deleting the field.

The balance to aim for is diagnostic completeness, confidentiality, and safe automated analysis held together. Maximum collection isn’t the goal. Enough evidence to explain a failure, and no more exposure than that requires, is.

The fastest way to learn logs and events is to look at your own application’s records rather than someone else’s diagram. Node.js apps report traces and logs to Kopai through OpenTelemetry auto-instrumentation, with no hand-written spans, so the setup is a short list of steps.

  1. Install the OpenTelemetry packages for Node.js and set a clear service name, because the service name is how you’ll filter later.
  2. Point the exporter at Kopai, so records leave your machine and become searchable.
  3. Make one request to a route that writes a log, such as signup.
  4. Confirm that traces, logs and metrics arriving from the app show up at app.kopai.app/observability, which proves the pipeline end to end.
  5. Pick one failed or unusual request, copy its trace ID, and find the matching log line.

That fifth step is the whole test. If the trace ID appears on the log line, your logs and events are ready for troubleshooting and any future incident starts from evidence. If it doesn’t, fix the logger setup before adding a single new log statement, because more records without correlation just means more to read.

A junior engineer can run these five steps without prior observability experience. If you’re not on Node.js, the same sequence applies with your language’s OpenTelemetry SDK: choose the SDK, set the same service name, point the exporter at Kopai, then check for the trace ID.


Kopai gives your coding agent the production evidence it needs to explain a failure instead of guessing at one: traces, logs and metrics collected through OpenTelemetry, searchable from the CLI or a dashboard, with the trace ID tying every record back to the request that wrote it. Set it up on one route this week and confirm that a failed request leads you to a named cause. Visit Kopai to connect your app and start reading the trail.

follow the build

One short note when something ships.

No spam. Unsubscribe anytime.