Skip to main content

Introduction

Every Tyk component writes an Application Log, capturing internal events of the system, such as health-checks, status, configuration changes, and errors, which are typically used for monitoring and debugging. Example
Three aspects can be configured:
  • verbosity: which severity levels are written
  • format: the structure and content of each entry
  • log output: where logs are sent, for example to a third-party aggregator
See Configuring Application and Access Logs for details of these and how to configure them. The rest of this page covers behavior specific to Tyk Gateway’s Application Log.

OpenTelemetry Trace and Span IDs

Gateway Only When OpenTelemetry tracing is enabled, Tyk Gateway automatically injects trace_id and span_id fields into all request-scoped application log entries, including middleware execution, error handling, and debug output. This lets you correlate an application log line with the corresponding span in your distributed trace.
Non-request-scoped entries (startup, configuration reload, health-checks) do not carry trace or span IDs because they are not associated with a specific request.

Tracking HTTP 404 Errors

Gateway Only By default, requests that do not match any configured API listen path return HTTP 404 and are not logged. Because these requests never enter the proxy pipeline, they are not recorded in Access Logs or API Traffic Logs, which only cover requests that are routed and processed by the Gateway. To track them in the application log, set track_404_logs to true in tyk.conf (or the equivalent environment variable). When enabled, a log entry is written at error level for each unmatched request. From Tyk Gateway 5.14.0, the entry includes a host field when using the text or json log format. Because Tyk Gateway exposes both a proxy API and a control API, and these can be configured on a separate hostname and port, the host field identifies which one received the unmatched request:
In legacy format, the host field is omitted:

Event Log Handlers

Gateway Only Event log handlers can be registered against Gateway events to write a log entry each time a specific event fires, such as an authentication failure or rate limit being exceeded.