Skip to content
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

feat(logs) separating access logs for admin and proxy reqs #1782

Merged
merged 1 commit into from
Nov 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kong/cmd/utils/prefix_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ local function prepare_prefix(kong_config, nginx_custom_template_path)
if not ok then return nil, stderr end
local ok, _, _, stderr = pl_utils.executeex("touch "..kong_config.nginx_acc_logs)
if not ok then return nil, stderr end
local ok, _, _, stderr = pl_utils.executeex("touch "..kong_config.nginx_admin_acc_logs)
if not ok then return nil, stderr end

log.verbose("saving serf identifier to %s", kong_config.serf_node_id)
if not pl_path.exists(kong_config.serf_node_id) then
Expand Down
1 change: 1 addition & 0 deletions kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local PREFIX_PATHS = {
nginx_pid = {"pids", "nginx.pid"},
nginx_err_logs = {"logs", "error.log"},
nginx_acc_logs = {"logs", "access.log"},
nginx_admin_acc_logs = {"logs", "admin_access.log"},
nginx_conf = {"nginx.conf"},
nginx_kong_conf = {"nginx-kong.conf"}
;
Expand Down
5 changes: 4 additions & 1 deletion kong/templates/nginx_kong.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resolver ${{DNS_RESOLVER}} ipv6=off;
charset UTF-8;

error_log logs/error.log ${{LOG_LEVEL}};
access_log logs/access.log;

> if anonymous_reports then
${{SYSLOG_REPORTS}}
Expand Down Expand Up @@ -62,6 +61,8 @@ server {
error_page 404 408 411 412 413 414 417 /kong_error_handler;
error_page 500 502 503 504 /kong_error_handler;

access_log logs/access.log;

> if ssl then
listen ${{PROXY_LISTEN_SSL}} ssl;
ssl_certificate ${{SSL_CERT}};
Expand Down Expand Up @@ -112,6 +113,8 @@ server {
server_name kong_admin;
listen ${{ADMIN_LISTEN}};

access_log logs/admin_access.log;

client_max_body_size 10m;
client_body_buffer_size 10m;

Expand Down
1 change: 1 addition & 0 deletions spec/01-unit/02-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe("Configuration loader", function()
assert.equal("/usr/local/kong/pids/nginx.pid", conf.nginx_pid)
assert.equal("/usr/local/kong/logs/error.log", conf.nginx_err_logs)
assert.equal("/usr/local/kong/logs/access.log", conf.nginx_acc_logs)
assert.equal("/usr/local/kong/logs/admin_access.log", conf.nginx_admin_acc_logs)
assert.equal("/usr/local/kong/nginx.conf", conf.nginx_conf)
assert.equal("/usr/local/kong/nginx-kong.conf", conf.nginx_kong_conf)
assert.equal("/usr/local/kong/kong.conf", conf.kong_conf)
Expand Down
1 change: 1 addition & 0 deletions spec/01-unit/03-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe("NGINX conf compiler", function()
assert.truthy(exists(tmp_config.nginx_kong_conf))
assert.truthy(exists(tmp_config.nginx_err_logs))
assert.truthy(exists(tmp_config.nginx_acc_logs))
assert.truthy(exists(tmp_config.nginx_admin_acc_logs))
end)
it("dumps Kong conf", function()
assert(prefix_handler.prepare_prefix(tmp_config))
Expand Down