Git Product home page Git Product logo

Comments (6)

alemuro avatar alemuro commented on June 6, 2024 1

Hi @samugi ! Thanks for answering 😄

Unfortunately, the KONG_NGINX_HTTP_LOG_FORMAT does not work for us, cause it is being used to set the log format, but it does not allow setting the if= directive 😞 .

Basically, we would like to apply the following Nginx configuration to ensure that 2xx and 3xx requests aren't logged:

map $status $loggable {
    ~^[23]  0;
    default 1;
}

access_log /dev/stdout combined if=$loggable;

This was achievable before (Kong <3.5) by setting KONG_PROXY_ACCESS_LOG="/dev/stdout combined if=$loggable", but now this is not possible cause:

  • The code forces to put the kong_log_format at the end of the line.
  • The only way to bypass this is by setting KONG_PROXY_ACCESS_LOG=<file> <format>. Otherwise, the string does not match this regex and the code puts the kong_log_format at the end of the line.

Many thanks!

from kong.

alemuro avatar alemuro commented on June 6, 2024 1

Hi again 👋

I found the root problem. I was using the kong docker image (kong:3.5) and I thought that it was using Kong 3.5.0.2 (kong version returns Kong 3.5). After replacing the image by the kong/kong-gateway:3.5.0.2 the issue is solved!!

Many thanks for your help 🙏

from kong.

alemuro avatar alemuro commented on June 6, 2024

I've reviewed the code and the affected line was changed here feat(request-id): introduce unique Request ID

from kong.

samugi avatar samugi commented on June 6, 2024

Hi @alemuro thank you for reporting this. I am looking into the issue you described, in the meantime, could you check if the problem is resolved by using the KONG_NGINX_HTTP_LOG_FORMAT variable to set the log format? Thank you.

from kong.

samugi avatar samugi commented on June 6, 2024

Hi @alemuro and thank you for the additional details provided.

I was able to reproduce the problem on 3.5.0.0, but I believe that should've been fixed by #12073, in fact, the regex you linked should match the string /dev/stdout combined if=$loggable. To make sure, I tested this on kong/kong-gateway:3.5.0.2-ubuntu and got the expected result, where conditional logging using the if keyword is accepted. Using your filter, the conditional logging was applied correctly to only log "non 2xx/3xx" status codes.

Can you try with the image I tested and let me know, and in case the problem can still be reproduced, provide some steps that include the exact image you are testing with? Thank you!

from kong.

samugi avatar samugi commented on June 6, 2024

thank you @alemuro !

from kong.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.