The Deska blog

Making Logs Consistent Enough to Query

Learn how to implement structural logging strategies to make logs consistent enough to query when building and debugging complex AI coding agent systems.

· 10 min read

Standard text logs are a staple of software development, but as we move toward autonomous systems, the traditional approach of printing strings to a console is no longer sufficient. When building tools or orchestrating multiple workflows, the primary challenge is making logs consistent enough to query. Without a predictable structure, identifying the specific failure point in a chain of five different agent calls becomes a manual chore rather than a data driven exercise.

The Problem with Human Readable Logs

Most developers start with simple print statements or basic logging levels. While these are easy for a human to scan during a live session, they are notoriously difficult to parse at scale. The lack of consistency creates several technical bottlenecks.

First, text based logs rely on regex for filtering. If one developer logs an event as User logged in and another as Login success for user, the queryability of the system breaks. Second, context is often lost. A timestamp and a message do not capture the state of the application, the specific version of the model being called, or the unique identifier of the session.

To solve this, we must shift from logging messages to logging data. This transition is essential for any modern development environment, especially when using complex orchestration tools.

The Anatomy of a Queryable Log

A log entry is consistent enough to query when every field is typed and every event follows a defined schema. There are four essential pillars to this approach.

  1. Schema enforcement. Every log must be a valid JSON object. This allows databases and search tools to index fields automatically.
  2. Contextual metadata. Every entry should include a trace_id or session_id. This allows you to reconstruct the entire journey of a single request across multiple services.
  3. Level discipline. Use levels like DEBUG, INFO, WARN, and ERROR strictly. An error should only be logged if an action is required, while info should represent state changes.
  4. Semantic naming. Use a flat structure for keys. Instead of nesting objects deeply, use keys like user_id and request_status to simplify filtering.

Implementing Structured Logging

Implementing these changes requires a library that supports structured output. In Python, libraries like structlog are excellent choices. In Node.js, pino or winston provide the necessary overhead to format logs as JSON without sacrificing performance.

When you implement structured logging, your output changes from this: 2023-10-27 10:00:00 - INFO - Agent started task 45

To this: {"timestamp": "2023-10-27T10:00:00Z", "level": "INFO", "event": "agent_task_started", "task_id": 45, "agent_name": "OpenCode"}

This change allows you to run queries such as "show me all tasks where the agent was OpenCode and the execution time exceeded 5 seconds."

How Different Tools Handle Log Visibility

Visibility tools differ in approach when it comes to presenting these logs to the developer. Traditional CLI tools often require piping output to secondary utilities like jq to make JSON readable. Cloud based observability platforms provide powerful dashboards but often introduce latency and high costs during the development phase.

Local environments provide a middle ground. For example, Deska handles logging by allowing you to run multiple terminal panels side by side. If you are running an agent like Claude Code in one panel and your backend logs in another, you can see the relationship between the two in real time. Because the workspace is an infinite canvas, you can zoom out to see the logs from several different containers or agents simultaneously.

Using the terminals panel in Deska ensures that you stay in a local-first environment while maintaining the high visibility required for debugging structured logs.

Comparison of Logging Strategies

The following table compares the three most common ways developers handle their console output during the development of agentic tools.

StrategySearchabilityImplementation EffortUse Case
Plain TextLowZeroSmall scripts and prototyping
Key-Value PairsMediumLowServer side applications
Structured JSONHighMediumProduction systems and AI agents

While JSON requires more setup, the long term benefits for queryability are undeniable. It transforms logs from a stream of text into a searchable database of system behavior.

Integrating Logs with AI Agents

When working with coding agents like Codex CLI or Claude Code, logs become even more critical. Since these agents are often making several decisions per minute, you need to know exactly what prompted a specific code change.

By using Deska, you can run these agents in dedicated panels within the canvas. If an agent makes a mistake, you can query your structured logs to find the exact prompt and response sequence that led to the error. You can even use the Ask Deska assistant to help you navigate your workspace or find specific logs by asking via voice or chat.

The ability to keep your data and storage local means that your logs, which might contain sensitive code snippets or API keys, never leave your machine unless you explicitly choose to move them.

Monitoring Logs on the Go

Sometimes development doesn't stop when you leave your desk. If you have a long running agent task, you might want check progress remotely. The mobile app for Deska allows you to pair your phone directly to your computer.

This setup lets you monitor your consistent logs from a different room or while traveling. Because the connection is a secure relay and doesn't expose ports, your structured logs remain private while you keep an eye on your agent's performance.

FAQ

How to make logs consistent enough to query in Python?

Use a library like structlog to force all output into a JSON format. Ensure all loggers in your application share a common configuration that includes a timestamp, log level, and a unique request ID for every transaction.

What is the best format for structured logging?

JSON is currently the industry standard for structured logging. It is supported by almost every log aggregator and is easy to parse with standard command line tools like jq or within custom developer environments.

Why are my logs hard to search?

Your logs are likely hard to search because they lack a fixed schema. If different parts of your application use different naming conventions for the same data point, or if important context like user IDs are buried inside long strings, search tools cannot index them effectively.

Start Building with Deska

Getting your environment ready for agentic development requires the right tools to visualize your data. Deska provides a free, local-first workspace that supports your logging needs through its infinite canvas and side by side panels. You can download the app for Mac, Windows, or Linux to begin organizing your workflow.

Visit the download page to get started with the workspace and explore how structured logging can improve your development cycle.

💡 Ideas+🐛 BugsSuggest a feature or report a bug