Capturing logs in authentik
When troubleshooting issues in authentik, reviewing the event logs can be invaluable. These logs provide continuous output, helping to diagnose problems effectively.
Adjusting log levels
The server and worker containers support multiple log levels: debug
, info
, warning
, and error
. By default, the log level is set to info
.
To modify the log level, follow the steps for your platform
- docker-compose
- Kubernetes
-
Add the following environment variable to your docker deployment:
AUTHENTIK_LOG_LEVEL=debug
-
Recreate your containers to apply the changes.
-
Add the following configuration to your
values.yml
file:authentik:
log_level: debug -
Recreate your containers to apply the changes.
Enabling trace
mode
The trace log level provides deeper insights, but be aware that using trace logs can expose sensitive information, including session cookies. Handle these logs with extreme caution and avoid using trace unless absolutely necessary.
To enable trace
logging, follow the platform-specific steps below:
- docker-compose
- Kubernetes
-
Add the following environment variable to your docker deployment:
AUTHENTIK_LOG_LEVEL=trace
-
Recreate your containers to apply the changes.
-
Modify your
values.yml
file:authentik:
log_level: trace -
Recreate your containers to apply the changes.
Viewing past logs
To review historical logs, you can use the --since
option with both docker logs
and kubectl logs
. This option allows you to specify either a duration (e.g., 1m30s
, 3h
) or a specific timestamp (e.g., 2006-01-02T07:00
, 2006-01-02
) to view logs generated after that point in time.
For more details, see the docker logs
documentation and kubectl logs
documentation.
- docker
- Kubernetes
To retrieve logs from a specific timeframe, use:
docker logs <container_name_or_id> --since 5m
To fetch logs from a Kubernetes pod:
kubectl logs --since 5m <pod_name>
Streaming logs in real-time
To continuously monitor logs, use the --follow
(-f
) option. This will stream log output to your terminal until manually stopped (Ctrl + C
or closing the terminal).
- docker
- Kubernetes
To follow logs in real time:
docker logs <container_name_or_id> -f
To stream logs from a Kubernetes pod:
kubectl logs -f <pod_name>