What Is a Log Record in OpenTelemetry?
A beginner-friendly guide to the standard shape of a single log entry: what fields it carries, how severity is expressed, how it links to traces, and how it travels from your application to a monitoring tool.
Imagine a ship’s captain who writes in a logbook every few hours. One entry might say, “Wind rising from the north, sails lowered.” Another might say, “Engine overheating, speed reduced.” Each entry has a time, a message and some importance. A good captain also notes which voyage and which ship the entry belongs to, so that years later an inspector can sort thousands of pages and find exactly what happened. Software keeps a logbook in the same way. Each line your program writes is one entry, and OpenTelemetry gives every entry a standard shape called a log record.
This guide starts from zero. You do not need to know what a log is, what a data model is, or why anyone would want to standardise something as simple as a line of text. We will build each idea step by step, using everyday comparisons and simple pictures, until you can explain a log record to a colleague with confidence.
1The Problem: Every System Writes Logs Differently
Before we define a log record, let us see the mess it was invented to clean up.
What is a log?
A log is a message that a program writes to describe something that happened. “User signed in.” “Payment failed.” “Disk almost full.” Programmers have written logs since the earliest days of computing because logs are simple, human-friendly and available everywhere. When something breaks at three in the morning, logs are often the first place an engineer looks.
The trouble with free-form text
For most of history, every program has written its logs in its own style. One writes the date first, another writes the severity first, a third writes everything in capital letters. One uses a dash as a separator, another uses a pipe. Some write plain sentences, and some write structured pieces of data. When a company runs hundreds of services written by dozens of teams, its logs become a pile of mismatched styles.
Searching this pile is painful. To find all errors, an engineer must know that one service says “ERROR”, another says “Err”, another says “SEVERE”, and another says “level three”. To find which logs belong to one customer request, they must guess from timestamps. Tools must be taught each style separately, using fragile text patterns that break whenever someone changes a message.
Imagine a library where every author formats their book differently: some put the title on the spine, some inside the cover, some on the last page, and some have no title at all. Finding a book would take forever. A standard cataloguing card, with the same boxes filled in for every book, would solve the problem at once. A log record is that standard card for log entries.
Many beginners think a log record is just “a line of text with a timestamp”. It is more than that. It is a small, organised bundle of named fields, where the message is only one field among several.
2A Quick Refresher: OpenTelemetry and Its Signals
Logs are one member of a family of three, so let us meet the family.
OpenTelemetry, often shortened to OTel, is an open-source project that defines a common way for software to describe its own behaviour. The data it describes is called telemetry, and it comes in three main kinds called signals.
Traces
The journey of one request through many services. They answer: where did this request spend its time?
Metrics
Numbers measured over time. They answer: how healthy is the system, and is something changing?
Logs
Timestamped records of events. They answer: what exactly happened at this moment, and in what words?
Resource
A description of who produced the data, such as the service name and environment, shared by all three signals.
The three signals are designed to work together. A metric raises the alarm, a trace shows where, and a log often explains why. For this teamwork to function, they must share common labels and identifiers. The log record is the piece that lets logs join that team.
Think of a hospital. The bedside monitor (metrics) beeps when something is wrong. The patient’s journey sheet (trace) shows which departments they visited. The nurse’s notes (logs) explain what was said and done. All three carry the same patient number, so the doctor can move between them in seconds.
3So, What Is a Log Record?
A plain definition first, then the reasons behind each word.
A log record in OpenTelemetry is a single, structured entry that describes one event at one point in time. It is made of a set of named fields, such as when the event happened, how serious it was, what the message said, who produced it, and which trace it belongs to. The standard that defines these fields is called the log data model.
That definition has three important ideas inside it.
A single entry
One log record describes one thing that happened. A thousand events produce a thousand log records, each one self-contained.
Structured, with named fields
Instead of a loose sentence, each piece of information has its own labelled box. A machine does not have to guess where the severity ends and the message begins.
A common data model
Every language and tool that follows OpenTelemetry uses the same field names and meanings. A log record from a Java service and one from a Python service look the same to a monitoring tool.
4The Anatomy of a Log Record
Every log record is built from the same handful of fields.
Learning these fields is the heart of this guide. Once you know them, you can read any OpenTelemetry log from any system. We will look at them in groups.
Group 1: When did it happen?
Timestamp
The time when the event actually occurred, as claimed by the source. This is the time the thing happened.
Observed Timestamp
The time when the system first noticed or collected the record. If a file was written at noon but read at five, the two times differ.
Group 2: How important is it, and what does it say?
Severity Number
A number from one to twenty-four that says how serious the event is, in a scale that is the same for every system.
Severity Text
The original word the source used, such as “WARN” or “Critical”, kept for human readers and for faithful records.
Body
The main content of the record. It can be a simple message or a structured set of values.
Event Name
An optional name that identifies the kind of event, when the record describes a well-defined occurrence rather than a free-form message.
Group 3: Which request does it belong to?
Trace ID
The identifier of the trace that was active when the record was written. It links the log to the whole journey of a request.
Span ID
The identifier of the specific span that was active. It links the log to one exact step of work.
Trace Flags
Small switches that travel with the trace, most importantly whether the trace was chosen for recording.
Group 4: Who wrote it, and what else is known?
Resource
Describes the producer: service name, version, environment, host or container. Shared by all signals from that service.
Instrumentation Scope
Describes which library or module created the record, together with its version.
Attributes
Extra key-and-value labels that add detail about this specific event, such as the route or the user’s region.
flowchart TD
LR["Log Record"] --> W["When: Timestamp, Observed Timestamp"]
LR --> I["Importance: Severity Number, Severity Text"]
LR --> C["Content: Body, Event Name"]
LR --> T["Trace link: Trace ID, Span ID, Trace Flags"]
LR --> O["Origin: Resource, Instrumentation Scope"]
LR --> A["Detail: Attributes"]
Think of a delivery receipt with labelled boxes: date and time, urgency, a description of the goods, the order number, the company that sent it, and a notes section. Because every box has a fixed place, anyone in the world can pick up the receipt and read it without a manual. A log record works the same way.
5Two Timestamps: When It Happened and When We Noticed
Having two times sounds odd, but it solves a real problem.
Imagine a security camera that records a burglary at 2 a.m., but the footage is only uploaded to the cloud at 9 a.m. If investigators looked only at the upload time, they would believe the burglary happened at nine. They need to know both: when it happened, and when the system first saw it.
Logs have the same issue. A program may write a line to a file at 2 a.m. A collection tool may only read that file at 2:05 a.m. The first is the Timestamp, the moment of the event as the source reports it. The second is the Observed Timestamp, the moment the record entered the telemetry system.
| Situation | Timestamp | Observed Timestamp |
|---|---|---|
| Application sends the log immediately | Event time | About the same as the event time |
| A tool reads an old file later | Time found inside the old line, if any | Time the tool read the line |
| The log has no time written inside it | May be unknown or empty | Time the system first saw it |
| A device was offline and sends a backlog | Original event times | Time the backlog arrived |
When logs seem to appear “late” or “out of order” in a tool, compare the two timestamps. A large gap between them tells you the delay is in collection or transport, not in your application.
Ignoring clocks. If the computers producing logs have clocks that disagree by even a few seconds, records from different services will appear in the wrong order. Keep server clocks synchronised with a trusted time service.
6Severity: Speaking One Language of Importance
Everyone agrees that an error is worse than a note, but they use different words for it.
Logging libraries each invented their own severity words. Some say “Debug”, “Info”, “Warning” and “Error”. Some say “Fine”, “Config” and “Severe”. Some use numbers where a larger number means worse, and others use numbers where a smaller number means worse. To compare logs across systems, a translation is needed.
OpenTelemetry solves this with two fields. The Severity Number is a standard scale from one to twenty-four, grouped into six families. The Severity Text keeps the original word, so nothing is lost in translation.
| Family | Severity Numbers | Meaning | Everyday Feel |
|---|---|---|---|
| Trace | 1 to 4 | Extremely detailed information for deep debugging | Every footstep along the path |
| Debug | 5 to 8 | Detailed information useful to developers | Notes to self while building |
| Info | 9 to 12 | Normal events that show the system working | “Order placed successfully” |
| Warn | 13 to 16 | Something unusual that may become a problem | “Disk is 85 percent full” |
| Error | 17 to 20 | Something failed, but the system continues | “Payment could not be processed” |
| Fatal | 21 to 24 | A serious failure that may stop the system | “Database connection lost, shutting down” |
Why four numbers in each family?
Within each family, the four numbers allow finer shades. The first number in a family is the plain level, and higher numbers mean slightly more severe versions of the same level. A source that has two kinds of warnings, one mild and one stronger, can map them onto two different numbers within the warning family. For most beginners, it is enough to remember the six families and their order.
Think of a traffic light system for weather warnings across many countries. Each country may describe a storm in its own words, but a shared colour scale of green, yellow, orange and red lets travellers compare at a glance. The severity number is that shared colour scale for logs.
Filtering by severity
Because severity is a number, tools can filter easily: “show me everything at error level or above” becomes “show records with a severity number of seventeen or more”. Systems can also decide to keep only certain levels in expensive storage and send the rest to cheaper storage.
Use severity honestly. If everything is logged as an error, nothing stands out. If real failures are logged as informational messages, alerts will never fire. Good severity discipline is one of the cheapest ways to make logs useful.
7The Body: The Heart of the Message
The body is where the actual content of the log lives.
The Body is the main payload of a log record. In the simplest case, it is a plain piece of text, such as “Payment declined by the bank”. But OpenTelemetry also allows the body to hold structured data: a list, or a set of named values. This flexibility lets the model carry logs from very different sources.
Unstructured body
A single sentence of free text. Easy for humans to read, but a machine must use text patterns to pull values out of it.
Structured body
A set of named values, such as an amount, a currency and a reason. A machine can read each value directly with no guessing.
Message plus attributes
A short readable sentence in the body, with details such as amount and currency stored separately as attributes. This combination is popular because it is friendly to both people and machines.
Structured logs are better logs
Compare two ways of recording the same event. In the first, the program writes a sentence: “Customer in Berlin paid 40 euros using a card”. In the second, it records a short message “Payment completed” with attributes for city, amount, currency and method. To count payments per city from the first form, a tool must read and parse sentences, and a small wording change breaks everything. From the second form, it simply groups by the city attribute.
Structured Logs
- Fields can be searched and grouped directly
- Wording changes do not break dashboards
- Easier to filter, count and alert on
- Less fragile processing in the Collector
Unstructured Logs
- Need text patterns to extract values
- A small wording change can break parsing
- Harder to count or group reliably
- More processing effort downstream
Keep the message short and stable, and put changing details into attributes. A message like “Payment failed” is easy to search and count, while “Payment failed for order 8841” produces a different message for every order.
8Trace Correlation: Connecting Logs to Requests
This is the feature that turns logs from isolated notes into pieces of a bigger story.
Suppose a customer’s checkout fails. Your logs contain millions of lines from dozens of services. Which ones belong to this customer’s request? Without a link, you must guess using time and luck. With OpenTelemetry, when a log is written while a span is active, the log record automatically carries the Trace ID and Span ID of that span.
Now the investigation is easy. In a tracing tool, you find the failed trace, note its trace ID, and ask the log tool for every record carrying that ID. You immediately see the messages written by every service that touched that request, in order. You can also go the other way: start from an error log, read its trace ID, and open the full trace to see the surrounding story.
sequenceDiagram
participant U as Customer
participant W as Web Service
participant P as Payment Service
U->>W: Click Buy
Note over W: Span A active, trace ID shared
W->>W: Writes log with trace ID and span A
W->>P: Call payment with trace context
Note over P: Span B active, same trace ID
P->>P: Writes error log with trace ID and span B
P-->>W: Failure reply
W-->>U: Error page with trace reference
A span is active
The application is doing traced work, so OpenTelemetry knows the current trace ID and span ID.
The program writes a log
It uses its normal logging library, with no special effort from the developer.
The identifiers are attached
The OpenTelemetry integration looks up the active span and copies its trace ID, span ID and flags into the log record.
The record is exported
The log record travels to the Collector and the backend with its identifiers intact.
Engineers jump between signals
From a trace, they find its logs. From a log, they find its trace.
Imagine a courier company that stamps the parcel number on every note a driver writes. A manager can pull up all notes for one parcel across every driver and depot, and read the full history in order. The trace ID is the parcel number stamped on every log.
Writing logs outside of any active span, for example in a background thread that lost its context. Those logs carry empty identifiers and cannot be linked to a request. Make sure context is passed into asynchronous work.
9Resource and Scope: Who Wrote This Record?
Two layers of context explain the origin of every log record.
A log message such as “connection timed out” is nearly useless without knowing which service wrote it and where it was running. OpenTelemetry attaches this information in two layers, and it does so once for many records instead of repeating it inside each one.
Resource
Describes the entity that produced the log: service name, service version, deployment environment, host name, container or cloud region. All records from one running service share the same resource.
Instrumentation Scope
Describes the library or module that created the record, such as a web framework or a database driver, together with its version.
Why resource matters so much
The resource is what lets a tool say “show me all error logs from the checkout service in production”. Without a clear service name and environment, logs from your test system and your live system get mixed together, and the owner of each log is a mystery. Because metrics, traces and logs all carry the same resource, you can line up everything from one service under one name.
Imagine a box of letters sent from one office. Instead of writing the office address on every single letter, you write it once on the outside of the box. Everyone who opens the box knows where all the letters came from. The resource is the label on the box, and each log record is a letter inside.
Always set a clear service name and an environment name. A log where the service is “unknown” is like an unsigned letter: you can read it, but you cannot tell who to call.
10Attributes and Event Names
The extra labels that make logs searchable and meaningful.
Attributes
An attribute is a pair made of a name and a value. It adds detail to one log record. For a log about a failed web request, useful attributes might include the route, the status code and the name of the region. Attributes are what let you ask “show me all errors for the checkout route in the Mumbai region”.
Following common names
OpenTelemetry publishes semantic conventions, which are agreed names for common attributes: for web requests, databases, messaging, cloud platforms and exceptions. When you use these standard names, any tool can recognise them. For example, if an exception is recorded using the standard attribute names for exception type, message and stack trace, a backend can group similar errors together automatically.
Event names
Not all log records are free-form messages. Some describe a well-defined occurrence, such as “a user signed in” or “a device was rebooted”. For these, the Event Name field gives the occurrence a stable, machine-friendly name. The record then behaves like a small structured event, with attributes defined for that particular name. This idea lets teams build consistent, queryable events on top of the log signal.
| Kind of Record | Has Event Name? | Typical Body | Typical Use |
|---|---|---|---|
| Free-form log | No | A sentence of text | General debugging and diagnostics |
| Structured event | Yes | Often empty or structured | Well-defined occurrences such as sign-ins |
| Exception record | Often yes | May hold the message | Capturing errors with type and stack trace |
Attaching attributes whose values are different for every record, such as a unique request number or a random token. They are rarely useful for grouping and can make storage and queries expensive. Keep unique identifiers to the trace ID, and keep attributes meaningful.
11How Log Records Are Created: The Logs Bridge
Developers keep using the logging tools they already know.
Most programming languages already have popular logging libraries, and teams have written millions of log statements using them. It would be unreasonable to ask everyone to rewrite all of that. So OpenTelemetry takes a different approach for logs than for traces and metrics. It provides a Logs Bridge API, and its main users are not application developers, but the people who build appenders or bridges for existing logging libraries.
An appender is a small plug-in for a logging library. Whenever your code writes a log through its familiar library, the appender catches the entry, converts it into an OpenTelemetry log record, and hands it to the OpenTelemetry SDK. Your application code does not change.
flowchart LR
A["Your code writes a log with a familiar library"] --> B["Appender or bridge converts it"]
B --> C["Logger creates a log record"]
C --> D["Log record processor batches records"]
D --> E["Log exporter sends over OTLP"]
E --> F["Collector"]
F --> G["Log backend and search tool"]
The pieces inside the SDK
Logger Provider
The factory that configures logging for the whole application and hands out loggers.
Logger
The object that creates log records on behalf of a bridge, tagged with the library’s scope.
Log Record Processor
Receives finished records and prepares them for sending, usually by grouping them into batches.
Log Record Exporter
Sends the prepared records to a destination such as a Collector, using the OpenTelemetry Protocol.
Think of a travel adapter. Your appliance keeps its original plug, and the adapter converts it to fit the foreign wall socket. The appender is the travel adapter between your existing logging library and OpenTelemetry. You keep the appliance and gain compatibility.
Because logs are batched before sending, a sudden crash may lose the last few records still waiting in memory. Make sure your application shuts down cleanly so the SDK has a chance to flush its batch.
12Two Roads to the Collector: Direct Export and File Collection
Logs can reach OpenTelemetry in more than one way.
Logs are special because many applications already write them to files or to the console, and many systems do not use OpenTelemetry at all. OpenTelemetry therefore supports two main roads.
Road 1: Send logs directly from the application
The application uses an appender and the SDK, and sends records over OTLP to a Collector or backend. Because the SDK creates the log record directly, it can attach the trace ID and span ID perfectly at the moment of writing, and it knows the resource precisely. This road gives the richest and most accurate records.
Road 2: Write to files and let the Collector read them
The application writes logs the way it always has, to a file or to the console, and a Collector running beside it reads the files. A receiver designed for file reading follows the file as it grows, splits the text into separate entries, extracts fields such as time and severity, and converts each entry into a log record. This road requires no change to the application and works for software you cannot modify, such as databases and third-party tools.
| Question | Direct Export | File Collection by Collector |
|---|---|---|
| Changes to the application? | Needs the appender and SDK | None |
| Trace correlation | Automatic and exact | Only if the app writes trace IDs into the text |
| Works for third-party software? | Usually no | Yes |
| Risk of loss on crash | Records in memory may be lost | Records already on disk are safe |
| Parsing effort | Little, since records are already structured | More, since text must be parsed |
flowchart LR
A1["App with OpenTelemetry SDK"] -->|"OTLP"| COL["Collector"]
A2["Legacy app writing log files"] --> F["Log files on disk"]
F -->|"File receiver reads and parses"| COL
A3["Database and other software"] --> F
COL --> P["Add resource, filter, redact, batch"]
P --> B["Log backend"]
Many teams use both roads at once: direct export for the applications they control, and file collection for everything else. If you write trace IDs into your text logs, even file collection can preserve the link to traces.
13The Collector and Log Records
The Collector is the workshop where raw logs become clean, safe, useful records.
The OpenTelemetry Collector is a separate program that receives telemetry, processes it, and forwards it. For logs, it offers several valuable abilities. Think of the Collector as the central sorting office for all your log records.
Parsing
Turn raw text lines into structured records by extracting time, severity, message and other fields. This is where messy legacy logs become tidy log records.
Enrichment
Add resource information such as the Kubernetes pod, namespace, cloud region and team name, so every record says where it came from.
Filtering
Drop records you do not need, such as very detailed debug messages in production or noisy health-check lines, to save cost.
Redaction
Mask or remove sensitive values such as card numbers, passwords and personal identifiers before records leave your network.
Batching and retry
Group records for efficient sending, and hold them in a queue with retries if the destination is temporarily unavailable.
Routing
Send different records to different destinations, such as security logs to one system and application logs to another.
Relying on the Collector alone to fix logs full of secrets. Redaction is a safety net, not a plan. The best approach is to avoid logging sensitive values in the first place, and use the Collector as a second line of defence.
14Logs, Traces and Metrics Working Together
Each signal is strongest when it can point to the others.
The real benefit of the OpenTelemetry log record is not that logs look prettier. It is that logs can finally join an investigation alongside traces and metrics, using shared identifiers and shared context.
Logs and Traces
Trace and span identifiers on each record let you move between a slow span and the messages written during it.
Logs and Metrics
A metric alert tells you when something changed. Logs from that window, filtered by service and severity, tell you what the system said.
Shared Resource
All three signals carry the same service name and environment, so everything from one service lines up under one name.
Shared Attributes
Using the same attribute names across signals, thanks to semantic conventions, lets one filter work everywhere.
A typical investigation
A metric alert fires
The error rate for the checkout service jumps. You know that something is wrong and roughly when it started.
You open a failing trace
The trace shows that the payment span is failing. You copy its trace ID.
You search logs by trace ID
Every log record written during that request appears, from every service, in time order.
You read the error record
An error-level record from the payment service shows the exception type and message, revealing the root cause.
Think of a detective who has a fire alarm panel (metric), a floor plan with a marked route (trace) and witness statements (logs). Each tool alone gives part of the story. With one shared case number, the detective can move from one to the other and put the whole story together quickly.
15What Should You Log? Practical Guidance
More logs are not always better logs.
Because logging is easy, many teams log far too much, and then pay for storage and search of lines nobody ever reads. Others log too little, and are blind during an incident. A few simple guidelines help find the balance.
Meaningful State Changes
Order placed, payment completed, user signed in, job started and finished. These tell the story of the business.
Failures with Context
Errors with the type of failure, the operation being attempted, and the relevant identifiers, but not secrets.
Unusual Conditions
Retries, fallbacks, timeouts and near-limits. These warn you before real failures occur.
Noisy Repetition
The same message thousands of times a second, or a line for every tiny step in a tight loop.
Secrets and Personal Data
Passwords, tokens, card numbers, full personal details. They should never appear in logs.
Logs as Metrics
If you only want to count something, use a metric. A counter is far cheaper than millions of log lines.
| Question You Want to Answer | Best Signal | Reason |
|---|---|---|
| How many orders per minute? | Metric | A counter is cheap and fast to chart |
| Why did this one order fail? | Log, with trace link | Needs the detailed message of one event |
| Where did this request spend its time? | Trace | Needs the timing of each step |
| Did anyone change this setting last night? | Log or event | Needs a record of a discrete occurrence |
A good test before adding a log line is to ask, “Who would read this, and when?”. If you cannot picture a person or a tool using it during a real problem, it may just be noise.
16Security and Privacy: Logs Remember Everything
Logs are one of the most common places where sensitive data leaks.
Because logs are written by programmers in a hurry, they often capture more than intended. A debug line that prints a whole request might include a password. An error message might include a customer’s email. Once written, a log may be copied to many tools and kept for months or years. Treat logs as sensitive data.
Never log secrets
Passwords, access tokens, keys and authorisation headers must never appear in logs. Review code for lines that print entire requests or configuration objects.
Minimise personal data
Avoid names, emails, phone numbers and government identifiers. If you must refer to a user, use an internal identifier that is meaningless outside your system.
Redact centrally
Use Collector processors to mask patterns such as card numbers and emails, as a safety net behind careful developers.
Protect the pipeline
Encrypt data in transit between applications, Collectors and backends, and restrict who can read, search and export logs.
Set retention deliberately
Keep logs only as long as needed for troubleshooting, security and legal requirements, then delete them.
Beware of log injection
If user-supplied text is written into logs unchecked, an attacker may insert fake lines or hide real ones. Structured records, where user input stays inside a field, reduce this risk.
Problem
A developer logs the entire incoming request at debug level, including headers and the full body, to make troubleshooting easier.
Why It’s Harmful
Passwords, tokens and personal details are copied into logs, stored in several systems, and readable by many people. A single leak or misconfiguration can expose customer data.
Correct Approach
Log only the specific fields needed, never headers carrying credentials, and add redaction rules in the Collector as a second line of defence.
17Best Practices and Anti-patterns
Habits that keep logs useful and affordable.
Good habits
Prefer structured logs
Keep a short, stable message and put changing details in attributes so machines can search and group reliably.
Use severity honestly
Reserve error for real failures and warn for things worth watching, so filters and alerts mean something.
Always attach trace context
Turn on the OpenTelemetry integration for your logging library so every record carries trace and span identifiers.
Set a clear resource
Define service name, version and environment once, so every record says who wrote it and where.
Follow semantic conventions
Use standard attribute names, especially for exceptions, web requests and databases, so tools understand your data.
Route logs through a Collector
It lets you parse, enrich, filter and redact in one place and change destinations without touching applications.
Review log volume regularly
Find the noisiest sources, remove pointless lines, and adjust levels so cost stays under control.
Mistakes to avoid
Problem
Every message is a long sentence with identifiers and values mixed into the text, such as “User 4821 failed to pay 40 euros for order 9937”.
Why It’s Harmful
Each message is unique, so grouping and counting require fragile text parsing. A small wording change breaks dashboards and alerts.
Correct Approach
Write a stable message such as “Payment failed” and attach user reference, amount and order as attributes.
Problem
All logs are written at the same severity, usually informational, regardless of how serious the event is.
Why It’s Harmful
Errors cannot be filtered or alerted on, and engineers must read everything to find problems.
Correct Approach
Map real failures to error severity, unusual conditions to warn, and normal activity to info, using the standard scale.
Problem
Debug-level logging is left on in production for every service, generating huge volumes.
Why It’s Harmful
Storage and search costs soar, performance suffers, and the useful lines disappear in noise.
Correct Approach
Default production to info or warn, allow debug temporarily for a single service when investigating, and filter noisy records in the Collector.
Problem
Logs are used to count events, such as writing a line for every request and counting lines to get the request rate.
Why It’s Harmful
Millions of lines are stored just to produce one number, which is slow and expensive compared with a simple counter.
Correct Approach
Use a metric for counts and rates, and keep logs for the details of individual events.
18Advantages and Trade-offs of Standard Log Records
A shared data model brings real benefits and a few limits.
Advantages
- One common shape for logs from every language and tool
- Built-in link to traces through trace and span identifiers
- Standard severity scale that makes filtering simple
- Shared resource and attributes across all three signals
- Works with existing logging libraries through appenders
- Supports both structured events and free-form messages
Disadvantages / Trade-offs
- Logs remain the most expensive signal at high volume
- Unstructured legacy logs still need parsing effort
- Correlation depends on context being passed correctly
- Batching may lose a few records if an application crashes
- Teams must agree on conventions to gain the full benefit
Logs, traces and metrics compared
| Signal | Best Question It Answers | Level of Detail | Typical Cost |
|---|---|---|---|
| Log | What exactly happened, in what words? | One event at a time | Can be high at scale |
| Trace | Where did this request spend its time? | One request at a time | Medium to high |
| Metric | Is something changing, and when? | Summary over time | Low and predictable |
“Now that I have traces, I do not need logs.” Traces show structure and timing, but they rarely carry full error messages and rich narrative detail. Logs still capture the human-readable story, and the two work best together.
19Real-World Scenarios
Picture how different teams use log records every day.
An online shop traces a failed order
A customer reports that their order failed. The support agent asks for the reference on the error page, which is the trace ID. Searching logs by that ID shows five records across three services, and the payment service’s error record explains that the card issuer declined the charge. The issue is resolved in minutes.
A platform team unifies messy logs
A company has forty services, each logging in a different style. By deploying Collectors that parse the files and convert them into log records with standard severity and resource labels, the team can finally search all errors across all services with one simple filter.
A bank protects customer data
A bank discovers that a debug line printed card numbers. The team adds a redaction rule in the Collector to mask card-number patterns immediately, then fixes the code and removes the line in the next release. Sensitive data stops flowing to storage within hours.
A streaming company cuts its logging bill
The monthly logging bill doubles. The team finds that one service writes thousands of identical informational lines per second. They remove the line, add severity filtering in the Collector, and use a metric for the count instead. Costs fall by half.
A manufacturer collects logs from machines
Factory machines write logs to local files and cannot run new software. Collectors beside them read the files, add machine and plant labels as resource attributes, and forward the records. Engineers can now compare error patterns across plants.
20Getting Started: A Gentle Path
You do not need to learn everything at once.
Pick one service and keep its logging library
Do not rewrite log statements. OpenTelemetry is designed to work with the library you already use.
Turn on the OpenTelemetry integration
Enable the appender or trace-correlation option for your logging library, and set a clear service name and environment.
Send records to a Collector and a viewer
Use a free open-source tool or your existing vendor, and confirm that records arrive with severity and resource filled in.
Check trace links
Open a trace, copy its trace ID, and search your logs. Seeing the matching records appear is the moment everything clicks.
Add file collection for everything else
Use a Collector to read files from software you cannot change, parsing time and severity into standard fields.
Add filtering and redaction
Drop noisy records, mask sensitive values, and review volume and cost regularly.
Your first goal is not perfection. It is to follow one real trace to its logs. When you click from a failing span to the exact error message in two steps, you will see why a standard log record matters.
21Frequently Asked Questions
It is one structured log entry in the standard OpenTelemetry shape. It holds fields for when the event happened, how serious it was, what it said, who produced it, and which trace it belongs to.
A log line is usually a single piece of text in whatever style the program chose. A log record organises the same information into named fields with agreed meanings, so any tool can read it without guessing.
The Timestamp says when the event happened, according to the source. The Observed Timestamp says when the telemetry system first saw it. Together they help you tell whether a delay is in the application or in collection.
It is a standard scale from one to twenty-four, grouped into trace, debug, info, warn, error and fatal families. It lets tools compare and filter logs from systems that use different severity words, while the severity text keeps the original word.
When a log is written while a span is active, the log record carries that span’s trace ID and span ID. You can then search logs by trace ID, or open the trace from a log’s identifiers.
No. OpenTelemetry provides bridges, also called appenders, for popular logging libraries. They convert your existing log calls into log records automatically, so your code stays the same.
It is the main content of the record. It can be simple text, or it can be structured data with named values. Many teams keep the body short and stable, and put changing details in attributes.
Yes. A file-reading receiver follows log files as they grow, splits them into entries, extracts fields such as time and severity, and converts each entry into a log record. This works even for software you cannot modify.
It is an optional field that gives a stable name to a well-defined occurrence, such as a sign-in. It turns a log record into a small structured event with attributes that belong to that name.
Use metrics. A counter is cheap, fast and designed for rates. Logs are for the details of individual events. Counting log lines to produce numbers is slow and expensive.
Do not log secrets or personal data in the first place, review code that prints whole requests, and add redaction rules in the Collector as a safety net. Also limit who can read logs and set sensible retention periods.
Yes. Metrics tell you that something changed, traces show where, and logs often explain why, in readable detail. The three signals are designed to work together, each filling gaps the others leave.
22Summary and Key Takeaways
A log record in OpenTelemetry is the standard shape of one log entry. Instead of a loose line of text, it organises information into named fields: a timestamp and an observed timestamp, a severity number and text, a body, an optional event name, trace and span identifiers, a resource, an instrumentation scope and attributes. This common shape lets logs from any language and tool be searched, filtered and compared in the same way, and lets them join traces and metrics through shared identifiers and context. Existing logging libraries feed the pipeline through bridges, so code rarely needs rewriting, and a Collector can parse, enrich, filter, redact and route records, including those read from plain files. Keep messages stable, put details in attributes, use severity honestly, attach trace context, protect sensitive data, and use metrics for counting, so your logs remain useful, safe and affordable.
Key Takeaways
- A log record is a structured entry — one event described through named fields, not just a line of text, using one data model for every language and tool.
- Know the main fields — timestamp and observed timestamp, severity number and text, body, event name, trace and span IDs, resource, scope and attributes.
- Severity speaks one language — a standard scale from one to twenty-four in six families makes filtering and alerting consistent across systems.
- Trace correlation is the superpower — records written during a span carry its trace and span IDs, so you can jump between a request and its exact log messages.
- Existing libraries keep working — appenders and bridges convert familiar log calls into log records, and Collectors can read plain files from software you cannot change.
- Structure beats free text — keep messages short and stable, put changing details in attributes, and follow semantic conventions so tools understand your data.
- Protect and control — never log secrets, redact centrally as a safety net, filter noisy records, and use metrics rather than logs for counting.