Most small AI deployments fail the same quiet way: something drifts, latency creeps up, a new error mode appears, or the monthly cost surprises you, and you have no clean record of when the change began. I learned this the hard way after the third time I found myself comparing screenshots and half-remembered prompt versions trying to reconstruct what had shifted.
This post describes the lightweight logging practice I now treat as mandatory for every Mistral Large 4 (and adjacent) workflow I run—local or API. It is deliberately boring. It requires no heavy observability platform, no vendor lock-in, and no extra services beyond what a normal home-lab or small-team machine already has. The goal is simple: when something changes, I want to know what changed, when it changed, and how much it cost me in time, tokens, or money.
If it only works in the demo, it isn’t in the workflow yet. A deployment that cannot answer basic questions about its own recent behavior is still a demo.
What I Actually Need to Know
For the workloads I run (extraction, coding assistance, RAG answers, weekly reports, family knowledge-base queries) the questions that keep recurring are:
How long did this call take, end to end?
How many tokens went in and came out?
Did the call succeed, and if not, what was the error class?
What did this cost (API dollars or local electricity/attention proxy)?
Which model version, quant, or endpoint produced the result?
Which prompt template or configuration was active?
If I can answer those from a single log stream or a simple daily/weekly summary, most debugging sessions become short instead of archaeological.
Design Principles for Small-Scale Logging
Four rules keep the system sustainable:
Log at the call boundary. Capture the data once, at the moment the request leaves my code and the response returns. Do not try to instrument every internal layer on day one.
Prefer structured, append-only records. JSON lines or a simple SQLite table beat free-form text when you later want to count or filter.
Keep the volume modest. Log every production call; sample or summarize aggressive debug traces. Disk is cheap until the logs become unreadable.
Make the log useful to a human first. I should be able to open today’s file and understand what happened without writing a query.
These principles rule out both “log nothing” and “ship everything to a full APM stack” for the scale I operate at.
The Minimal Record I Capture for Every Call
Each inference call writes one structured record containing:
timestamp (UTC)
request_id (short unique ID)
endpoint or runtime identifier (API vs local, and which quant or model revision)
prompt_template_id or hash (so I know which instructions were active)
input_token_count
output_token_count
latency_ms (client-side wall time from send to full response)
status (success / error)
error_class and error_message (if any)
estimated_cost (API dollars or a local proxy such as “GPU-seconds”)
task_type (extraction, coding, rag, report, etc.)
optional free-text note (usually empty)
That is enough to answer the recurring questions without turning every call into a novel.
How I Implement It in Practice

API Path
A thin wrapper around the HTTP client records the start time, sends the request, records the end time, parses the usage fields from the response (or estimates them if the provider is stingy), and appends the JSON line. Failures are caught and logged with the same schema so the success/error ratio stays visible.
Local Path
The same wrapper talks to the local OpenAI-compatible endpoint. Token counts come from the runtime when available; otherwise I estimate from character length with a consistent factor and accept the small inaccuracy. Latency is still client-side wall time—the number that actually affects the user or the next pipeline stage. GPU-seconds or a simple “duration × estimated power” figure serves as the cost proxy.
Shared Conventions
Both paths write to the same log directory with daily files (inference-2026-10-12.jsonl). A single schema keeps later analysis trivial. Rotation is handled by the daily filename; old files are compressed and eventually archived according to a simple retention rule.
I deliberately do not log full prompts and completions in the default production path. Those belong in a separate, optional debug stream or in the evaluation harness. The operational log stays small and less sensitive.
Turning Records into Weekly Visibility
Raw JSON lines are necessary but not sufficient. Once a week I run a short script that produces a one-page summary:
total calls by task_type and by endpoint
success rate and top error classes
latency percentiles (p50, p95)
total input/output tokens and estimated cost
any noticeable day-over-day or week-over-week change
I read that summary the same day I review the rejection logs for the RAG and support pipelines. Patterns appear quickly: a sudden rise in timeout errors after a runtime update, a gradual climb in average input tokens after a prompt change, a cost spike when a new workflow was accidentally left in double-generation mode.
The script is ordinary Python—pandas or even just the standard library. No dashboard is required. When I later want a dashboard I can add one; the data is already clean.

Error Classification That Helps Instead of Noise
I map raw exceptions into a small set of classes:
rate_limit
timeout
invalid_response (JSON parse failure, unexpected schema)
content_filter or refusal
runtime_error (local OOM, CUDA issues, etc.)
unknown
This mapping turns a wall of stack traces into counts I can act on. “We had 14 timeouts on Thursday” is actionable. “There were some errors” is not.
Cost Tracking Without Illusions
For the API the cost field is straightforward multiplication of token counts by the published rates (or the rates I actually pay). For local inference I record GPU-seconds and, when I care, convert to an electricity estimate using a measured average draw under load. I do not pretend the local cost is zero; I just make the proxy explicit so I can compare workloads fairly.
Attention cost—the time I spend reviewing outputs or debugging—is logged separately in the failure notebook. It does not fit neatly into the inference log, yet it often dominates the true expense of a workflow.
Privacy and Retention
Because some workloads touch personal or internal data, the default operational log contains no raw text. Request IDs let me join to a more detailed debug store when I need to investigate a specific failure. Retention for the operational logs is measured in months, not years; the weekly summaries are kept longer. This keeps disk use and exposure modest.
What Changed After I Started Logging This Way
Three concrete improvements appeared within the first month:
I caught a prompt-template change that had silently increased average input tokens by roughly 30 %. The weekly summary made the jump obvious.
A local runtime update introduced intermittent timeouts that only occurred under longer contexts. The error_class counts and latency percentiles pointed at the problem before users (including me) became consistently annoyed.
Cost attribution became honest. I could finally say which workflows were driving the API bill and which local workloads were consuming the most GPU time.
None of these required a sophisticated platform. They required consistent records and the habit of looking at the weekly page.
Practical Implementation Checklist
Wrap every production inference call with a single logging function.
Use a fixed schema and daily JSONL files (or an equivalent SQLite table).
Capture latency on the client side; it is the number that matters to the next stage.
Record model/endpoint identity and prompt-template identity on every line.
Map errors into a small, stable set of classes.
Generate a one-page weekly summary and actually read it.
Keep raw prompts/completions out of the default operational log.
Treat the logging path itself as critical: if the logger fails, I want to know.
What I Still Don’t Know
I have not yet built automatic alerting on the weekly metrics; I still rely on the human reading step. I have not integrated the same log stream with the evaluation harness so that quality scores and operational metrics live in one view. I have not stress-tested the logging path under much higher call volumes. Those are open improvements, not reasons to delay the basics.
The current practice is good enough that I notice problems while they are still small. That is the entire design goal.
Closing
Logging latency, tokens, errors, and cost is not glamorous infrastructure. It is the difference between a deployment you can reason about and a deployment you can only hope is still behaving. For a small AI system—home lab or small team—the lightweight approach above has been sufficient and sustainable.
Here is what I controlled, here is what changed, and here is what I still don’t know. The controlled part is the logging discipline itself. The rest continues every time a weekly summary shows a number that does not match the previous week.
If it only works in the demo, it isn’t in the workflow yet. And if you cannot tell how the workflow behaved last Tuesday, it is not yet a deployment you fully own.

No comments yet.