By default, Tyk components (dashboard, gateway, pump, MDCB, identity broker) generate logs in info mode (level=info). Info mode provides a general overview of the component's activities.
time="Sep 20 04:43:06" level=info msg="Reload queued" prefix=main
time="Sep 20 04:43:06" level=info msg="reload: initiating" prefix=main
However, if you need to troubleshoot issues or gain deeper insights into each component's behaviour, you can enable logs in debug mode. Debug mode allows Tyk components to emit more verbose logging about the events and processes running.
Debug mode increases computing overhead by logging more information than the standard
or typical logging process, so be sure to only enable it when necessary.
Enabling Debug Mode via Configuration File
For the Tyk gateway, you can enable debug mode by modifying the
tyk.conf configuration file. Locate the
log_level parameter and set its value to
debug. Save the changes and restart the gateway service. You can do the same for other components like:
- Dashboard =>
- Pump =>
- MDCB =>
The Identity Broker does not have a field to configure the
log_level. If more or
less information is needed for TIB, kindly use the environment variable settings.
In the case of the developer portal, the field to modify is the
LogLevel property in the
Enabling Debug Mode via Environment Variable
You can also enable debug mode for any Tyk component by setting the TYK_LOGLEVEL environment variable to
debug. This method is applicable to all Tyk components, including the dashboard, pump, MDCB, identity broker, and gateway.
The exception to this rule is the developer portal, as the variable to set is PORTAL_LOG_LEVEL.
Setting the Environment Variable for Different Deployment Scenarios
- For Virtual Machines (VM)
systemctl edit tyk-gateway
systemctl restart tyk-gateway
- For Docker file
- For Docker run command
docker run --env TYK_LOGLEVEL=debug tykio/tyk-gateway:v5.2.1
docker run -e TYK_LOGLEVEL=debug tykio/tyk-gateway:v5.2.1
- For Docker compose
Restart the gateway container with:
<your gateway container name or id>
- For Helm Chart deployment
- name: TYK_LOGLEVEL
Recreate the gateway pod via the helm upgrade command.
helm upgrade tyk-pro tyk-helm/tyk-pro -f values.yaml -n
Verifying Debug Mode
Once you have enabled debug mode, you should start seeing more detailed log messages with a level of
debug. These messages provide in-depth information about the component's internal operations, aiding in debugging and troubleshooting.
time="Sep 19 12:18:57" level=debug msg="Primary instance set, I am master" prefix=host-check-mgr
time="Sep 19 12:18:28" level=debug msg="Upstream request took (ms): 36.263529"
Check if the environment variable TYK_LOGLEVEL is set inside the gateway pod:
$ kubectl describe pod <gateway-container-pod> -n
<your namespace>Environment: TYK_LOGLEVEL: debug
Check if TYK_LOGLEVEL is set inside the gateway docker container:
$ docker exec
<your gateway container name or id>printenv | grep TYK_LOGLEVEL