When an order gets stuck in a dealer portal, the trace of the problem is scattered across five services, three servers and lines written in five different styles. Connecting to servers one by one and searching text files costs minutes, sometimes hours. Centralized log management means collecting the logs of all your applications and servers in one place, giving them a common structure, making them searchable and keeping them for a defined period.
In this guide we cover log levels, structured logging, a field standard, the correlation id, collection architecture, volume and retention cost, alerting from logs and a six-step setup. All figures are illustrative; they are not the price of a specific tool or an industry average.
What Is Centralized Log Management, and How Does It Differ from Monitoring and Audit Logs?
Centralized log management gathers the lines that describe what your software did into a single search surface. Three kinds of records are often confused; each answers a different question and has a different owner.
| Topic | Monitoring (metrics) | Application log | Audit log |
|---|---|---|---|
| Question answered | Is it healthy? | Why did it break? | Who changed what? |
| Unit | Number, time series | Event line | Business-data change |
| Lifetime | Long, summarized | Short and tiered | Policy-driven |
| Reader | On-call, management | Developer, support | Auditor, manager |
We covered the metric, log and trace distinction and error budgets in our software monitoring guide, and recording changes to business data in our audit log article; we do not repeat them here.
Recommended reading: Incident management and post-mortems
What Are the Log Levels, and Which Should Be On in Production?
Four levels are enough, and in production the default should be info and above, with debug switched off.
| Level | When it is written | In production |
|---|---|---|
| Error | Operation failed, someone must look | Always on |
| Warning | Unexpected, but processing continued | Always on |
| Info | Important business event (order created) | On, kept sparse |
| Debug | Detailed internal state | Off; enabled briefly and narrowly |
Reserve the error level for cases that truly need action. Counting every caught exception as an error erases the meaning of the level and buries real errors in noise. If you must enable debug, do it for a single correlation id or for 30 minutes, and let it switch itself off when the time is up.
Why Is Structured Logging Better Than Free Text?
In structured logging every line is a record of field-and-value pairs (usually JSON); in free text the meaning is buried inside a sentence. The difference shows up when you search and count.
| Topic | Free text | Structured |
|---|---|---|
| Example | Order 1042 stock insufficient, item K-88 | event=stock_short, order=1042, item=K-88 |
| Search | Regular expression; breaks when the pattern changes | Field match |
| Counting | Lines are parsed, then counted | Group by field |
| Line size (example) | 180 bytes | 350 bytes |
The cost is clear: the same information takes about 350 ÷ 180 = 1.94 times the space. The volume and sampling math below keeps that manageable, and in return you can ask every question as a query.
Which Fields Should Every Log Line Contain?
All services must write the same small set of fields; otherwise searching across services is impossible.
| Field | Description | Rule |
|---|---|---|
| time | The moment the event happened | UTC, millisecond precision |
| service, environment | Who wrote the line, where it runs | Fixed names (orders, production) |
| level | Error, warning, info, debug | Limited to four values |
| message | Short human-readable text | Contains no variable values |
| correlation_id | End-to-end identity of the request | Mandatory |
| user_digest | A digest or code for the user | Not name or e-mail |
Keep variables out of the message: "Stock insufficient" is a fixed message, while the item code is a separate field. That way you can count and group the same event.
How Do You Trace One Request Across Five Services with a Correlation ID?
A correlation id is a unique value created when a request enters the system and passed to every service in a header; every log line carries it.
Take an order flow across five services: gateway, orders, stock, payment and notification. It produces 2 + 3 + 2 + 3 + 1 = 11 lines. Without an id you must search by time window: at 150 requests per second and 6 lines per request, a window of just ±1 second is 2 × 150 × 6 = 1,800 lines, and you pick 11 out of them by hand. Searching by id returns exactly 11 lines, about 164 times fewer.
The id must also survive asynchronous work: a queued message should carry it, and a scheduled job should create its own id and record the triggering request's id in a separate field. For queue design see our message queue article.
What Should Never Be Written to Logs?
Passwords, card numbers, access keys, session tokens and unnecessary personal data are never written to logs; a log is a place many people can read and that lives on in copies for a long time.
- Do not write whole request bodies; select only the fields you need.
- Mask sensitive fields at write time; cleaning the store afterwards is already too late.
- Refer to users by code or digest rather than by name.
- For pre-write scanning and secret detection see our secure software development article.
How Do You Build the Collection Architecture?
On each server an agent reads the log, a buffer or queue holds it temporarily, and the central store indexes it. The application should not write to the network directly; it writes to local output first, so a slow network does not slow the application.
The buffer size determines how much log you lose while the store is unreachable. The numbers: 150 × 6 = 900 lines per second at 350 bytes produce 315,000 bytes per second.
- The store is unreachable for 10 minutes (600 s): 900 × 600 = 540,000 lines, about 189 MB.
- A 100 MB memory buffer holds 100,000,000 ÷ 350 ≈ 285,714 lines and fills after about 317 s (5.3 min); the remaining 254,286 lines, or 47.1%, are lost.
- A 1 GB disk buffer lasts about 52.9 minutes; in the same outage the loss is zero.
When the buffer fills, drop debug and info lines first and keep errors and warnings. If error and warning lines are 3% of the total, a 10-minute outage means 540,000 × 0.03 = 16,200 lines, about 5.7 MB, which fits easily in a 100 MB buffer. Priority dropping takes critical loss to zero with the same memory.
How Do You Calculate Log Volume and Apply Sampling?
Volume is the product of request rate, lines per request and line size; doing the math up front prevents cost surprises.
150 requests/s × 6 lines × 350 bytes × 86,400 s = 27,216,000,000 bytes, about 27.2 GB per day (decimal), or 816.5 GB per month. If debug is left on and lines per request rise from 6 to 24 (4 times), daily volume becomes 108.9 GB and a 30-day total 3,265.9 GB. That is why debug is enabled for a limited time only.
Sampling reduces volume. Keep 10% of successful requests and 100% of requests that contain an error or warning; say 2% of requests contain one. The kept share is 0.98 × 0.10 + 0.02 × 1.00 = 0.118, so volume is 27.2 × 0.118 ≈ 3.2 GB per day, an 88.2% reduction. Sample by request, not by line; otherwise only half of a request survives and tracing by correlation id breaks. Increment counters before sampling so the total request count is not lost.
How Do You Plan Retention Tiers and Index Cost?
Not every log is searched at the same speed; recent logs are searched often, old ones rarely. So retention is split into tiers. The periods are operational examples, not legal retention periods; for retention obligations consult your legal counsel and accountant.
| Tier | Period | Access | Unit price (per GB-month, illustrative) |
|---|---|---|---|
| Hot | First 7 days | Instant, fully indexed | ₺12.00 |
| Warm | Days 8–30 | Seconds, partial index | ₺3.00 |
| Cold | Days 31–180 | Minutes, via restore | ₺0.60 |
Index cost grows with the number of fields. An illustrative rule: hot-tier storage = raw volume × (1 + 0.1 × indexed field count). With eight fields the multiplier is 1.8; with twenty it is 3.0. Instead of indexing every field, index only those you search by (service, level, correlation id, event).
Monthly cost for the 3.2 GB per day example: hot 7 × 3.21 × 1.8 × 12 ≈ ₺485.6; warm 23 × 3.21 × 3 ≈ ₺221.6; cold 150 × 3.21 × 0.60 ≈ ₺289.0. The total is about ₺996. The same table across four scenarios looks like this.
| Scenario | Monthly cost |
|---|---|
| No sampling, all 180 days hot | ₺105,816 |
| No sampling, tiered | ₺8,442 |
| Sampled, all 180 days hot | ₺12,486 |
| Sampled and tiered | ₺996 |
The two measures multiply each other. Raising indexed fields from 8 to 20 moves the last scenario to ₺1,320 (+₺324). For archive details see our data archiving article, and for general cloud bill management our FinOps guide.
How Do You Generate Alerts from Logs?
Generating alerts by scanning the log store every minute is expensive; creating counters while logs stream is cheap. Turn indicators such as error rate into counters in the collection pipeline and attach the alert to the counter.
The math: a 5-minute window is 900 × 300 = 270,000 lines; a query that scans every minute reads 270,000 × 1,440 = 388,800,000 lines per day. A counter counts the log once and never scans the store. Threshold example: in 5 minutes there are 150 × 300 = 45,000 requests; the normal share of HTTP 500 responses is 0.4%, or 180 errors; the threshold is 2%, which is 900 errors, and if it lasts 5 minutes the alert fires. Build this logic together with the alerting principles in our monitoring article.
Search examples should be ready too: requests with code 500 in the last 15 minutes (135,000 × 0.004 = 540 requests), or all lines of one correlation id. The on-call engineer should know these two queries by heart.
How Does Timestamp Drift Break Log Order?
If service clocks differ, lines appear in the wrong order. Say in a request the gateway writes at 0 ms, the orders service at 40 ms and the stock service at 90 ms. If the stock server's clock is 2 seconds behind, the stock line carries a timestamp of 90 − 2,000 = −1,910 ms and appears even before the gateway. The drift is about 20 times larger than the time between steps.
The fix has two parts: enforce clock synchronization on all servers and monitor the drift; also carry a sequence number that increases within the same source. The goal is for drift between clocks to stay smaller than the time between steps.
Who Can Access Logs, and Why Does It Matter?
Logs can contain personal data and business secrets, so access is role-based: developers read environment logs, the support team reads logs where the user digest is visible, and only authorized people read raw logs. Queries should be recorded too. For role and permission design read our API security article. The period personal data may remain in logs and data protection obligations are left to your legal counsel.
What Are the Cost and Payback of Centralized Log Management?
The gain is shorter incident resolution time. Illustrative assumptions: 6 incidents per month, average resolution time falls from 60 to 25 minutes with a correlation id and searchable logs (35 minutes), a minute of loss costs ₺200, setup is 14 person-days × ₺9,000 = ₺126,000, and monthly operation is 1.5 person-days = ₺13,500.
Monthly gain is 6 × 35 × ₺200 = ₺42,000. With ₺996 of storage, net is 42,000 − 13,500 − 996 = ₺27,504. Payback is 126,000 ÷ 27,504 ≈ 4.6 months. With 3 incidents a month, net is ₺6,504 and payback about 19.4 months. The calculation does not count engineer time or lost sales; redo it with your own numbers.
Track six measures monthly: daily volume, query p95 time (example target 2 s), loss rate (9,000 missing out of 9,000,000 lines = 0.1%; under target), structured log share (14 of 20 services = 70%; target 95%), indexed field count and the share of lines carrying a correlation id.
How Do You Run a Centralized Log Management Rollout?
Six steps are enough; each step should leave a written output.
- Write down the levels and the field standard; provide a shared library or template.
- Create the correlation id at the edge and carry it to all services, queues and jobs.
- Mask sensitive fields; add a check before writing.
- Set up the agent, buffer and store; compute the buffer size from volume.
- Decide tiers, sampling and indexed fields; measure the cost.
- Build alerts from counters and review the six measures monthly.
This setup is even more valuable in multi-service architectures; see microservices architecture and scalability.
We recommend reading: How to Manage Bot Traffic and Automated Abuse: Signal Scoring, Rate Limits and Payback Guide
We recommend reading: How to Run Integration Operations: Error Queues, Reprocessing and Monitoring Dashboards
We recommend reading: How to Measure and Improve Mobile App Performance and Crash Rate: Indicators, Crash Analysis and Performance Budget Guide
Custom Software and Production Logging with İnovabil
At İnovabil our focus is building custom software from scratch for your company: custom software, ERP, CRM, e-commerce, web, mobile and integration. Our process page records the steps of analysis, design, development, testing, release, maintenance and support; we recommend writing down log levels, the field standard and retention periods during the requirements stage.
We have built CRM, purchasing and mobile for Avcılar İnşaat; a purchasing system for İZBAN; logistics and shipment planning with wholesale order management for Karyak; and warehouse management plus a complaint and support management system for Sleepy. Send a short summary of the critical flows in your current system and we will write the logging requirements together.
Recommended reading: Our software development process and our custom software service
Frequently Asked Questions
What is centralized log management?
It is a setup where the logs of all applications and servers are collected in one place, given a common structure, made searchable and kept for a defined period. It lets you find the cause in minutes without visiting server after server.
Why is structured logging needed?
Field-and-value pairs mean search and counting no longer depend on parsing patterns. The same information takes about 1.94 times the space, but you can ask every question as a query.
What is a correlation id?
A unique value created when a request enters and passed to every service. Because each line carries it, one search returns the 11 lines of an order across five services.
How long should logs be kept?
The operational example is 7 days hot, 30 warm and 180 cold. Legal retention periods are separate; consult your legal counsel and accountant.
How do you reduce logging cost?
Keep debug off in production, sample successful requests, store in tiers and index only the fields you search by. In the example these measures cut the monthly cost from ₺105,816 to ₺996.