-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor add LOG_FORMAT option #3274
Conversation
Hi! Customizing the log format from the configuration file would be handy. However, I'm not sure about the approach followed in this patch. The
But the current patch would specify a log_format directly appended to the
It is also my belief that we should be able to define multiple logging formats instead of a single one (one might want to use a different format for the proxy or the admin access logs altogether, for example), so we should probably try to support that in the configuration file as well. |
Thanks @thibaultcha for the reply. Not sure if you understood me correctly, so I'll try to add more explanation with simpler example. My main idea was to have mechanism to add/change So assuming my
I should be able to switch between formats like this:
Otherwise it should fallback to default which is
This allows me to not ever touch nginx_kong.lua and makes my template upgrade proof. So if you guys decided to delete any of |
I see, so this solution still requires one to create their own nginx configuration template (as per the default main template) in order to define their custom logging format... I find this a little bit obscure to use. Usually, I would be a fan of a solution that fully plays into the Kong model (abstract away the Nginx directives), or fully plays with the Nginx approach (when made obvious that such customizations would require an Nginx configuration change). But this approach sits in the middle, which I find unintuitive to use... |
This reverts commit c3bb2b1.
@thibaultcha I refined a bit the solution. |
Look forward to this pr! I want to customize the default access log in kong in order to hide basic_auth's username defined in |
@ymatsiuk Sorry, I don't understand what this patch is supposed to do, nor how it differs from the original one. As a user, I'd still have to specify my custom logging format in a custom nginx configuration template, so the configuration of a logging format is still split between the two files... (The I think I will close this until we come up with a better integration. For now, this can still be achieved with a custom nginx template. |
@thibaultcha with this idea there is no need to create custom temple. All you need is to set few env variables. So in the
And you can start kong defining 2 environment variables to have custom format:
Otherwise kong will fallback to default |
@ymatsiuk Since this is now doable via #3530, I don't think there is a need for this PR anymore - we followed a more generic and powerful approach, due to the pains experienced in having to maintain a plethora of Nginx directive aliases in our own configuration file. Nonetheless, thank you for the patch! |
Summary
According to this https://getkong.org/docs/0.12.x/configuration/#custom-nginx-configuration-embedding-kong there are two ways of using custom template:
nginx_kong.lua
in globalFirst method is pretty cool and easy. And it doesn't break in case of change in
nginx_kong.lua
. So it's a pretty solid way to add functionality. Second method involves more maintenance as every update we have to check what was changed in templates, backport the changes into our custom template and try to re-build image (yes we run docker).Desired way of defining log format for nginx:
But in current situation we need to inline whole
nginx_kong.lua
in order to appendaccess_log...
withjson
in the end.Full changelog
nginx_kong.lua
templatekong.conf.default