Troubleshoot APIs faster with correlated application logs

Apitally now captures and correlates application logs with API requests, so you get the full picture of what happened when troubleshooting issues.

Simon GurckeSimon Gurcke//1 min read

We’re excited to announce a new feature in Apitally: application logs. This builds on our request logging feature by capturing log messages emitted during request handling, and surfacing them right alongside request and response details in the request logs.

Request logs are great for understanding API interactions. Our users have found it incredibly useful to drill down from a high-level overview to the headers and payloads of specific requests.

But what about the magic that happens between the request and response? Sometimes, the real story is in your application’s internal logic. By capturing log messages, Apitally gives you that additional context when troubleshooting issues.

Getting started

Like request logging, capturing application logs is an opt-in feature. You can enable it using a configuration option in your integration code (e.g. capture_logs in Python). Make sure you have the latest version of the Apitally SDK installed.

from fastapi import FastAPI
from apitally.fastapi import ApitallyMiddleware

app = FastAPI()
app.add_middleware(
    ApitallyMiddleware,
    client_id="your-client-id",
    env="dev",  # or "prod" etc.
    enable_request_logging=True,
    # ... other options ...
    capture_logs=True,
)

How it works

Once enabled, the Apitally SDK automatically instruments common logging libraries, captures log messages, and associates them with requests. The implementation is language-specific:

  • Python: We add a log handler to the root logger of the standard logging library.
  • JavaScript: We monkey-patch the console object, as well as Pino, Winston, and NestJS loggers (depending on the framework used).
  • .NET: We register a logger provider by adding an implementation of ILoggerProvider to the application’s service collection.

Availability

Our Python, JavaScript, and .NET SDKs have been updated to support capturing application logs. The feature is available to all users on the Starter and Premium plans, with different monthly quotas, as outlined in our pricing table.

Support for Go and Java coming soon!