Skip to content

feat: enable L4 stream logging#5768

Merged
spacewander merged 4 commits into
apache:masterfrom
bisakhmondal:stream_log
Dec 13, 2021
Merged

feat: enable L4 stream logging#5768
spacewander merged 4 commits into
apache:masterfrom
bisakhmondal:stream_log

Conversation

@bisakhmondal

@bisakhmondal bisakhmondal commented Dec 10, 2021

Copy link
Copy Markdown
Member

What this PR does / why we need it:

closes #5400

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Comment thread conf/config-default.yaml Outdated
stream:
enable_access_log: true # enable access log or not, default true
access_log: logs/access_stream.log
access_log_format: "$remote_addr [$time_local] $status $bytes_sent $session_time $upstream_connect_time \"$protocol://$upstream_addr\""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

@spacewander spacewander left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread apisix/cli/ngx_tpl.lua Outdated

access_log {* stream.access_log *} main buffer=16384 flush=3;
{% end %}
open_log_file_cache max=1000 inactive=60;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it, as the log file name doesn't contain variable. There is only one open log file.
See https://nginx.org/en/docs/http/ngx_http_log_module.html#open_log_file_cache

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. Thanks

Comment thread apisix/cli/ngx_tpl.lua

access_log {* http.access_log *} main buffer=16384 flush=3;
{% end %}
open_file_cache max=1000 inactive=60;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

Comment thread conf/config-default.yaml Outdated
# - TEST_ENV

stream:
enable_access_log: true # enable access log or not, default true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread conf/config-default.yaml Outdated
stream:
enable_access_log: true # enable access log or not, default true
access_log: logs/access_stream.log
access_log_format: "$remote_addr [$time_local] $status $bytes_sent $session_time $upstream_connect_time \"$protocol://$upstream_addr\""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bisakhmondal

Copy link
Copy Markdown
Member Author

Could you add a test in https://github.com/apache/apisix/blob/master/t/cli/test_access_log.sh? Thanks.

Done. Took a while to figure out how to set up mock upstream.

Comment thread t/cli/test_access_log.sh Outdated
exit 1
fi

make stop

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will clean up automatically, so there is no need to add it. See

make stop || true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks for sharing the details. Updated.

@spacewander
spacewander merged commit 71c256b into apache:master Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request help: How to enable logging for the four-layer proxy stream route?

3 participants