The recognized values for logging are: error
, warn
, info
, debug
, and trace
.
For a more detailed explanation of logging in Chef Habitat, see the Supervisor Log Configuration Reference and the Supervisor Log Key documentation.
To turn on and examine the services debug logging in your Habitat installation:
-
Edit the
sudo /hab/svc/builder-api/user.toml
file -
On the first line, change the log_level from error to debug
log_level="debug,tokio_core=error,tokio_reactor=error,zmq=error,hyper=error"
-
Save and close the file
-
Restart Habitat with
sudo systemctl restart hab-sup
. -
Use
journalctl -fu hab-sup
to view the logs. -
Reset
/hab/svc/builder-api/user.toml
file to the defaultlog_level=error
and restart the services withsudo systemctl restart hab-sup
to restore error-level logging.
-
Use
RUST_LOG=debug RUST_BACKTRACE=1
to see an individual command's debug and backtrace.# Linux/MacOS # replace "hab sup run" with your command env RUST_LOG=debug RUST_BACKTRACE=1 hab sup run
-
Edit the
sudo /hab/svc/builder-api/user.toml
file -
On the second line, change:
RUST_LOG=debug RUST_BACKTRACE=1
The builder-api-proxy
service will log (via Nginx) all access and errors to log files in your service directory. Since these files may get large, you may want to add a log rotation script. Below is a sample logrotate file that you can use as an example for your needs:
```bash
/hab/svc/builder-api-proxy/logs/host.access.log
/hab/svc/builder-api-proxy/logs/host.error.log
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
/bin/kill -USR1 `cat /hab/svc/builder-api-proxy/var/pid 2>/dev/null` 2>/dev/null || true
endscript
}
```