use log.SetFormatter intead of the no-mutex version, safe api use
if TYK_LOGOUTPUT=stdout env is defined, the output goes to stdout
tested with:
# TYK_LOGOUTPUT=stdout ./tyk | head -n 1
time="Oct 02 18:32:06" level=info msg="Tyk API Gateway v5.5.0-dev" prefix=main
# git status .
On branch improvement/logging
Alternatively the same can be achieved with 2>&1, but that's hard to inject into the container, especially with distroless where there isn't a shell available.
Alternative options / extensions of our logging behaviour:
in the real world outside it's common to log the usual stuff into stdout, and log anything with error or above into stderr, from me 3 years ago.
consider file logging, where logs get split into error.log, debug.log, info.log, warning, error...
file logging but also consider log rotation a-la logrotate.d
My immediate other thought was to configure syslog:
// Enable Syslog log output
UseSyslog bool `json:"use_syslog"`
// Syslong transport to use. Values: tcp or udp.
SyslogTransport string `json:"syslog_transport"`
// Graylog server address
SyslogNetworkAddr string `json:"syslog_network_addr"`
Discarded this idea quickly, as you'd actually have to have syslog in the distroless env. Syslog could be configured to log the output to file(s), but it seems as an unnecessary hop when you want to terminate the log data flow inside the container.
This PR does:
tested with:
Alternatively the same can be achieved with
2>&1
, but that's hard to inject into the container, especially with distroless where there isn't a shell available.Alternative options / extensions of our logging behaviour:
error.log
,debug.log
,info.log
, warning, error...My immediate other thought was to configure syslog:
Discarded this idea quickly, as you'd actually have to have syslog in the distroless env. Syslog could be configured to log the output to file(s), but it seems as an unnecessary hop when you want to terminate the log data flow inside the container.