travisghansen / external-auth-server

easy auth for reverse proxies
MIT License
330 stars 44 forks source link

Logging in JSON format #123

Closed nonefaken closed 3 years ago

nonefaken commented 3 years ago

Hello,

is there an easy way to configure EAS output all logging information in JSON format?

By default the logs are not in JSON format and i have to chain it though Fluent-bit instance through regex parser, ie. Regex ^(?<eas_log_header>[^\{]*) (?<eas_json_log>[^*]*)$.

This is not critical, but not very convenient, especially in kubernetes, then often platform by default only supports logs to stdout in JSON format, else it is like constant "playing with drums".

Thank you!

travisghansen commented 3 years ago

Are you running in k8s? It does json by default there.

travisghansen commented 3 years ago

https://github.com/travisghansen/external-auth-server/blob/master/src/logger.js

Basically it looks for NODE_ENV=production

nonefaken commented 3 years ago

It helped :) Thank you!

docker logs eas -f
{"service":"external-auth-server","level":"info","message":"revoked JTIs: []"}
{"service":"external-auth-server","level":"info","message":"starting server on port 8080"}