Types of Logs
Tyk generates four types of logs:- Application Log: Internal system events such as health-checks, configuration changes, and errors.
- API Traffic Log: Gateway A record of every API request, written into Redis and processed by Tyk Pump for analytics and reporting.
- Access Log: Gateway Per-request server logs intended for external log aggregators. Similar to API Traffic Logs in that both record individual requests, but Access Logs are lightweight and real-time whereas API Traffic Logs are richer and processed asynchronously.
- Audit Log: Dashboard A record of user actions in Tyk Dashboard, such as API changes and login events.
Configuring Application and Access Logs
Tyk Gateway, Tyk Pump, Tyk Dashboard, Tyk MDCB, and Tyk Developer Portal each write an Application Log tostderr, handled in a typical installation by the service manager running the process.
Tyk Gateway’s Access Log uses the same underlying logger, so every setting that applies to Tyk Gateway’s Application Log also affects the Access Log.
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
Global Settings
Two environment variables apply across multiple components and override any component-specific setting:Component Settings
When global variables are not set, each component can be configured individually using environment variables or the equivalentlog_level and log_format settings in its configuration file.
All components default to info verbosity and text format. Tyk Developer Portal is an exception: it defaults to prod format, which is equivalent to json.
The
legacy format was introduced in Tyk Gateway 5.14.0 and Tyk Pump 5.14.0 to maintain backward compatibility for existing users with log pipelines reliant on the precise log content. See legacy format.Severity and Verbosity
The severity of a log is an indication of its likely importance to the system administrator. The system will generate logs at four different levels of severity:
Each component can individually be configured to output only the logs generated at or above a given severity level by setting the log level as follows:
error: only errors are loggedwarn: warnings and errors are loggedinfo: errors, warnings, and informational messages are logged (default)debug: all of the above, plus detailed diagnostic output
Access Logs have
info level severity. Setting Tyk Gateway’s log level to warn or error therefore suppresses Access Log output. There are additional controls for the generation and content of access logs as described in Access Logs.Format Options
Log format controls the structure and timestamp style of application and access logs generated by a component. The supported values aretext (default), json (recommended), and legacy.
- Text Format
- JSON Format
- Legacy Format
Legacy Format
From Tyk Gateway 5.14.0 and Tyk Pump 5.14.0, thetext and json formats use RFC3339 timestamps and a standardized message field.
If your log pipeline relies on the previous timestamp format (Dec 12 13:50:45) or the msg field key, set log_format to legacy to preserve the old behavior.
Log Output
By default, application and access log output is written tostderr.
Tyk Gateway and Dashboard can also forward logs to a third-party aggregator, in addition to stderr:
Add the relevant settings to
tyk.conf for Tyk Gateway, or tyk_analytics.conf for Tyk Dashboard (or use the equivalent environment variables):
- Sentry
- Logstash
- Graylog
- Syslog
GatewayDashboard
use_sentry: Set totrueto enable output to Sentry.sentry_code: The Sentry-assigned DSN (endpoint URL) to which the logs are sent.
Configuring Traffic Logs
Traffic Logs are generated by Tyk Gateway and written to Redis, notstderr, so none of the settings above apply to them. Enable them by setting enable_analytics in the Gateway configuration; see Dashboard Analytics for how Tyk Pump then processes and routes them from Redis.
Configuring Audit Logs
Audit Logs are generated by Tyk Dashboard and configured through its ownaudit.* settings block, unrelated to the Application Log settings above. See Audit Logs for the full configuration reference, or Enable and View Audit Logs in Tyk Dashboard for a step-by-step guide.