Replies: 5 comments 11 replies
-
@JMLX42 Why two environment variables? #2151 only uses one, and it seems like a suitable approach to me. |
Beta Was this translation helpful? Give feedback.
-
I haven't tested it, but I think you can currently customize the log format by doing the following:
|
Beta Was this translation helpful? Give feedback.
-
I've looked around on how JSON-formatted logging can be configured. Even the latest changes/commits do not include that I've tinkered around a bit with the log formatting configuration. I can polish it further if needed. Let me know. |
Beta Was this translation helpful? Give feedback.
-
I'm sure people might not like us removing ' and breaking old configs. Happy to redo that PR to |
Beta Was this translation helpful? Give feedback.
-
Rationale
Today, the
log_format
is hardcoded:https://github.com/nginx-proxy/nginx-proxy/blob/2f898566fcf20f36e29a6265dc42e56587c59eba/nginx.tmpl
Some might need to use a different format string. In our case, we need to include
$request_time
because we want to use Loki + Graphana to chart our APIs response time.AFAIK:
log_format
string without editing the template$access_log
Proposal
Add the
VIRTUAL_LOG_FORMAT
andDEFAULT_LOG_FORMAT
environment variables. Such environment variable would be set to thestring
expected argument of thelog_format
NGINX directive:https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
Example to add
$request_time
to the access logs:VIRTUAL_LOG_FORMAT
use it. Otherwise useDEFAULT_LOG_FORMAT
.DEFAULT_LOG_FORMAT
is not set, use the hardcoded default value.Thus, this addition would be 100% backward compatible.
Beta Was this translation helpful? Give feedback.
All reactions