QA Interview Hub · Knowledge base · Quizzes · Українська

Logs and observability

Logs for a QA

What a log entry holds and what the levels mean

A log entry has a time, a level, a source, a message and context, and the level says how serious the event is. Time is written in UTC per ISO 8601. The logger has a threshold: entries below it are dropped, so a missing entry does not prove the event did not happen. Expected situations such as a wrong password are INFO or WARN, while ERROR is for an operation that failed.

Logs · Basics

A test failed, and the logs are clean. Was there really no error?

A user complains that a payment "hung". The logs for that time have no ERROR, and the tester’s report is about to be closed as "cannot reproduce". An hour later it turns out that a catch block caught the gateway exception, wrote an INFO line and moved on. The log existed, it just had the wrong level and the wrong fields. This lesson covers what a log entry consists of, what each level means, and how to tell "there was no error" from "the error was not recorded".

How it works and why. A log entry is a structure of several fields. The event time is best written in UTC per ISO 8601 / RFC 3339 with milliseconds (2026-10-12T09:14:03.512Z): local time without a zone gets confusing when you investigate across servers. The level (severity) says how serious it is. The source: service, instance, class, thread. The message: what happened. The context: a request id or trace id, an internal user id, an error code, a stack trace.

How to read a log entry

12026-10-12T09:14:03.512Z 2ERROR 3checkout-7d9f [http-4] Payment failed
  4orderId=8841 traceId=4bf92f3577b34da6a3ce929d0e0e4736
  GatewayTimeoutException: no response in 3000 ms
  1. Time. UTC per ISO 8601 with milliseconds; the letter Z means UTC. Without a zone, times on different servers cannot be matched.
  2. Level. Alerts are usually set on ERROR: an INFO entry does not trigger one. It is what tells "there was no error" from "the error was logged at the wrong level".
  3. Source. The service, the instance and the thread, then the message: where exactly it happened.
  4. Context. orderId and traceId: they find the entry in other services’ logs. A stack trace without them is just noise.

What to do

Provoke a failure in a test environment and check all four parts in the entry. A missing time zone, ERROR level or id is a logging defect, not a detail.

Figure 1. An example log entry: the numbers lead to the explanations.

The levels are ordered, and a logger has a threshold: entries below it are dropped before output. This exists so production does not pay storage and CPU for every step. The threshold is set in the logger configuration and can differ per package: the payments service on INFO, the HTTP client library on DEBUG. So "nothing in the logs" often only means the needed level is switched off in this environment. Names differ a little between libraries (Python has CRITICAL, java.util.logging has SEVERE and WARNING, syslog defines eight levels in RFC 5424), but the order and the idea are the same.

Levels and the threshold

FATALthe app cannot continueERRORan operation failed, needs attentionWARNodd, but the system copedINFO ← typical production thresholdmeaningful lifecycle eventsDEBUGdeveloper details: not visibleTRACEevery step: not visible
Figure 2. With an INFO threshold, DEBUG and TRACE are filtered out before writing. To see them, the threshold is lowered temporarily for the needed package.

Example: an error nobody saw. The starting code:

try {
  gateway.charge(order);
} catch (Exception e) {
  log.info("failed");      // not ERROR, no id, no stack trace
}

Three defects: the exception is swallowed (the code goes on as if all is well), an INFO level will not trigger an ERROR alert, and the message has neither the order nor the stack. The fix:

try {
  gateway.charge(order);
} catch (GatewayTimeoutException e) {
  log.error("Payment failed orderId={} traceId={}",
      order.id(), traceId, e);   // exception as the last argument
  throw e;
}

Now the entry carries context for searching, an exception with its stack, and lands in ERROR. The exception is rethrown, so the caller decides what to do, and the log does not replace error handling. A tester checks exactly this: provoke a failure (an unreachable gateway in a test environment) and see what appears in the logs.

Which level for which event.

EventLevelWhy
A user typed a wrong password (401)INFO / WARNan expected situation, not a system failure
The gateway did not answer, the retry succeededWARNthe system coped, but it signals instability
The payment failed after all retriesERRORthe operation was not completed, attention needed
Required configuration cannot be read at startupFATAL / ERRORthe service cannot continue

Limits and alternatives. Levels are a team convention, not a law: somewhere INFO is noisy, somewhere ERROR is logged for every 404. So QA checks the service’s real practice, not the textbook one. A log is also not guaranteed to be complete: a threshold, sampling and losses when a container restarts mean a missing entry does not prove the event did not happen. For "how many" and "how fast", metrics are more reliable, and for a request path across services, traces.

Typical mistakes.

  • A swallowed exception: the logs are clean while the user sees a failure.
  • Validation rejections (400) at ERROR level: the noise hides real failures and people stop reading the alert.
  • A stack trace without context (no order or request id): there are thousands of entries and the needed one cannot be found.
  • Time without a zone: a gap of hours against the server’s UTC.
  • A password, token or full card number in the message: a leak through the logs.

Check yourself

A service runs with an INFO threshold. A developer says "the detailed log exists", but you cannot see it. What do you check first?

Answer

The level of that entry. If it is DEBUG, the INFO threshold dropped it before output. Lower the level for the needed package in the test environment (logger configuration or an environment variable) and reproduce the failure again. Old entries will not appear: dropped entries are not stored.

A user typed a wrong password and the service wrote an ERROR with a stack trace. A defect or the norm?

Answer

More likely a logging defect: this is an expected scenario, not a system failure. Alerts are set on ERROR, so thousands of wrong passwords create noise and hide real errors. INFO or WARN without a stack is enough, ideally with a counter in the metrics to detect password guessing.

In an interview. Junior: A log holds a time, a level, a source, a message and context. Levels run from TRACE to FATAL, and the threshold decides what is visible. I check that an error really lands in ERROR and that the entry has no passwords. Middle/Senior: Beyond that I look at the service’s practice: whether exceptions are swallowed, whether expected validation pollutes ERROR, whether a request id exists to link to a trace, whether time is in UTC. I know a missing entry does not prove the event did not happen (threshold, sampling, loss on restart), so for quantitative questions I use metrics.

Structured and plain-text logs

A plain-text log is a line written for a human, while a structured log records an event as field-value pairs, most often one-line JSON. A field is pulled from plain text with a regular expression, and any change of wording breaks the search, whereas stable field names and error codes avoid this. The stack trace goes into one field. Checks and alerts are tied to fields, not to a phrase.

Logs · Formats

How do you find every payment failure when each entry words the message differently?

A developer changed the message from "Payment failed" to "Could not process the payment", and a script that counted failures with grep silently shows zero. The test is green, there are "no failures". This is the typical result of plain-text logs: a machine searches for a substring in a phrase written for a human. This lesson covers the difference between plain-text and structured logs, why production moves to JSON, and what this gives automated tests.

How it works and why. A plain-text log is a free-form line. It is easy for the eye, but to extract a field from it you have to parse the phrase with a regular expression (grok in Logstash, regex in a collection agent), and any change of wording breaks the parser. A structured log writes the event as a set of "field: value" pairs, most often JSON on one line. Parsing comes down to standard JSON parsing, and a field has a stable name that changes less often than the message text.

2026-10-12 09:14:03,512 ERROR [checkout] Payment failed for order 8841: gateway timeout
2026-10-12 09:14:03,640 ERROR [checkout] Payment failed for order 8842: gateway timeout
{"ts":"2026-10-12T09:14:03.512Z","level":"error","service":"checkout",
 "msg":"payment failed","orderId":8841,"error":"gateway_timeout",
 "traceId":"4bf92f3577b34da6a3ce929d0e0e4736","durationMs":3004}

Another format often seen in Go and the Loki ecosystem is logfmt (level=error msg="payment failed" orderId=8841): "key=value" pairs separated by spaces. It is more readable than JSON but handles nested objects worse. The point is the same: a field is separated from the text.

The same query against a log

Text

grep for a substring

Depends on wording, case and word order. Editing the message silently breaks the check.

JSON

Filter on a field

The error field and the number durationMs are stable. You can compare, group and count.

Figure 1. A structured entry lets you search by a field value, not by a phrase.

Example: the same search in two formats. The text variant:

# text: count payment failures for orders ending in 1
grep "Payment failed" app.log | grep -c "order [0-9]*1:"
# works only until someone changes the wording of the message

The expression is tied to the words "Payment failed", the position of the order number and the colon. The structured variant depends on none of these:

# JSON: a field and a value, the message wording does not matter
jq -c 'select(.error=="gateway_timeout" and .durationMs > 3000)' app.log
# count by error code
jq -s 'group_by(.error) | map({error: .[0].error, n: length})' app.log

The takeaway: a check "every payment failure in the last hour with a timeout over 3 s" is written on fields (error, durationMs), not on a phrase. In Kibana that is a KQL filter, in Loki | json | error="gateway_timeout", in a terminal jq.

Rules of a good structured log.

  • One event is one line: the stack trace goes into a field ("stack") as a string instead of being spread over dozens of lines.
  • Common field names across all services (traceId, userId), otherwise search across the system falls apart. A ready schema is often used, such as Elastic Common Schema.
  • A stable error code ("error":"gateway_timeout") next to the text: the code for the machine, the text for the human.
  • Do not log large request and response bodies whole: volume and leak risk.

Limits and alternatives. A structured format does not fix bad logs: a field "msg":"error" is useless in any format. JSON is hard to read by eye, so locally developers turn on a "pretty" output and keep JSON in production. Multi-line exceptions in a text format can be torn by an aggregator into separate entries:

2026-10-12 09:14:03,512 ERROR [checkout] Payment failed
java.net.SocketTimeoutException: Read timed out
    at ...
2026-10-12 09:14:03,640 INFO  [checkout] Retry scheduled

Here a line with at ... and the next INFO, unless a multi-line rule is configured, are seen by the aggregator as separate events. For QA this means: when looking for a root cause, check that the whole stack collected into a single event.

Typical mistakes.

  • An automated test looks for an exact message phrase in a log: it breaks on every wording change.
  • Different names of one field in different services (user_id, userId, uid): one query does not find everything.
  • A stack split into several entries: the "first error" in a search looks empty.
  • Values of different types in one field (orderId is a number, then a string): the storage index rejects some entries.

Check yourself

A test looks for the string "Payment failed" in a log and turned green after a refactoring, although failures exist. What happened and how do you make the check robust?

Answer

The message was reworded and the substring no longer matches, so the search finds nothing and a "no failures" check passes. Search on a stable field (error code, event type) in a structured log, and also add a check that the result is not empty where at least one entry is expected.

Why is a stack trace put into one field of a JSON log instead of being left as many lines?

Answer

An aggregator reads a log line by line and treats each line as a separate event. A multi-line stack falls apart and the link to the error is lost. In one field all frames stay part of one event, and a search by request id finds the full stack.

In an interview. Junior: A plain-text log is a phrase for a human, a structured one is field-value pairs, often JSON. The second is easier to search and analyse automatically. Middle/Senior: I tie automated checks and alerts to stable fields and error codes, not to wording. I look at common field names across services, at the stack being a single entry, and at value types: a type mismatch in a field breaks indexing. For humans, a readable format stays available locally.

Where to find logs and how to localise a bug with them

A bug is localised from the user inward: Console and Network, then backend logs by request id. A 5xx points to the server, while a 4xx most often points to data or authorisation. Later ERRORs are usually a cascade, so the earliest error with the same id is sought. A bug report includes the environment, the time with its zone, the request id and a short log excerpt without secrets.

Logs · Investigation

The "Pay" button gives an error. Where do you look for the cause: the browser or the server?

A tester sees "Try later" after paying. Opening the whole cluster and scrolling the logs makes no sense: there are thousands per minute. There is a short route that in most cases shows within a few steps where it breaks: the frontend, the request or deeper in the services. This lesson covers where logs live in different environments and how to localise a bug with them so that a developer can reproduce it without clarifications.

Where the logs live.

  • Browser: DevTools → Console (JS exceptions, console.error, resource load errors) and Network (statuses, bodies, headers).
  • Backend: container stdout/stderr (docker logs, kubectl logs), files on a server and, in mature systems, a central store (ELK/OpenSearch, Loki, Datadog).
  • CI: the job console and artifacts (service logs, reports, traces).
  • Mobile: Android: adb logcat and the Logcat window in Android Studio. iOS: the Xcode console, the Console app and the log tool; for a simulator xcrun simctl spawn booted log stream. Crash reports are collected by services such as Crashlytics or Sentry.

How it works and why. A user request passes several layers: browser, gateway, services, database. Each layer writes its own log, and an error in one produces a cascade in the next. So the route goes from the user inward and stops at the first error in the chain. What was written last (dozens of ERRORs from different services) is mostly consequences. The link between layers is held by a request identifier: without it you match entries by time and guesses.

The investigation route

1. Record time and environmentwith the zone, build version2. Console and Network in DevTools5xx, 4xx, a JS exception?3. Take the request id from the responseX-Request-Id or trace id4. Find backend entries by the idservices that touched the request5. Find the FIRST errorand what came before: WARN, a deploy
Figure 1. Steps 1-3 are done in the browser and the test client, steps 4-5 in the backend logs.

Example: from "Try later" to the cause. In Network the POST /api/payments request returned 504, and the response header has X-Request-Id: 7c1e5a90. This already says the frontend did its part (the request went out) and the problem is deeper: 5xx means the server side, while 4xx is more often about data or authorization. In the log store a filter on this id and the time gives a chain:

09:14:00.470 WARN  checkout   retry 1/2 gateway=acme reason=timeout
09:14:03.512 ERROR checkout   gateway timeout 3000 ms orderId=8841
09:14:03.515 ERROR api-gw     upstream checkout returned 504

The last entry (ERROR in api-gw) is a consequence. The first error is in checkout, and before it a WARN about a retry. The cause is an unstable payment gateway, not the UI. Such a report already points to a service. For comparison: without an id the tester writes "payment does not work", and the developer spends an hour among thousands of entries.

What to add to a bug report.

Steps: pay for an order by card 4242 in staging
ER: status "Paid". AR: error "Try later"
Environment: staging, build 2.14.0, 2026-10-12 09:14:03 UTC
Request: POST /api/payments -> 504, X-Request-Id: 7c1e5a90
Log (shortened): checkout ERROR gateway timeout 3000 ms orderId=8841
First in the chain: WARN retry 1/2 ~3 s earlier

Here each line saves a question: the environment with a build, time with a zone, the request id and a shortened log excerpt. The excerpt is cut to a few lines around the first error, with secrets and personal data removed.

Mobile logs. Device logs are mixed with system noise, so they are narrowed:

adb logcat -v time *:W          # Android: WARN and above
adb logcat -c                    # clear the buffer before reproducing
adb logcat --pid=$(adb shell pidof -s com.example.shop)

Limits and alternatives. The route does not work if the logs are not there: a threshold that is too high, logs on a pod that is already deleted, short retention. Then the bug is reproduced with a raised level and the logs are collected at once. If the backend in a stand is shared, other people’s requests land in the results: narrow by id. For rare failures it is more reliable to have an alert and a trace than to hope someone opens DevTools in time.

Typical mistakes.

  • Taking the last error instead of the first: treating a consequence.
  • Forgetting the time zone: the logs use UTC, the report uses local time, and the entry "cannot be found".
  • A screenshot of the error without a request id and time: the developer cannot match it to the logs.
  • Pasting a log with a token or personal data into a bug report.

Check yourself

In Network the request returned 400 and the console has no exceptions. Where to look next: the frontend or the backend?

Answer

The request reached the server and was rejected. This is often data or authorization, so first the response body with the error description and the request body itself (what the client sent). Then, by request id, see why the backend rejected it. If the request body is wrong, the cause is on the frontend; if it is correct and the 400 is wrong, it is on the backend.

The log search shows dozens of ERRORs from different services within one second. Which do you start with?

Answer

With the earliest one by time carrying the same request id. The others are usually a cascade: a client service failed because a dependency returned an error. Then look at what came before the first one (WARN, retries, a deploy, a configuration change) to understand not only what but why.

In an interview. Junior: I reproduce the bug, record the time with a zone, look at Console and Network, take the request id and search for it in the backend logs. In the report I add steps, environment, time, the id and a log excerpt. Middle/Senior: I look for the first error in the chain, not the last, and check what came before it. By status I distinguish: 5xx is the server, 4xx is most often data or authorization, a missing request or a JS exception is the frontend. If there are no logs, I raise the level, reproduce and collect again, and also check that services pass the request id on.