Skip to content

Commit

Permalink
Merge pull request #836 from coryfklein/master
Browse files Browse the repository at this point in the history
Make log format json escaping configurable
  • Loading branch information
aledbf authored Jun 11, 2017
2 parents 816b7f5 + fa70e5e commit ecb9515
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions controllers/nginx/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ type Configuration struct {
// Default: 4 8k
LargeClientHeaderBuffers string `json:"large-client-header-buffers"`

// Enable json escaping
// http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
LogFormatEscapeJson bool `json:"log-format-escape-json,omitempty"`

// Customize upstream log_format
// http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
LogFormatUpstream string `json:"log-format-upstream,omitempty"`
Expand Down Expand Up @@ -311,6 +315,7 @@ func NewDefault() Configuration {
KeepAlive: 75,
KeepAliveRequests: 100,
LargeClientHeaderBuffers: "4 8k",
LogFormatEscapeJson: false,
LogFormatStream: logFormatStream,
LogFormatUpstream: logFormatUpstream,
MaxWorkerConnections: 16384,
Expand Down
2 changes: 1 addition & 1 deletion controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ http {
# disable warnings
uninitialized_variable_warn off;

log_format upstreaminfo '{{ buildLogFormatUpstream $cfg }}';
log_format upstreaminfo {{ if $cfg.LogFormatEscapeJson }}escape=json {{ end }}'{{ buildLogFormatUpstream $cfg }}';

{{/* map urls that should not appear in access.log */}}
{{/* http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log */}}
Expand Down

0 comments on commit ecb9515

Please sign in to comment.