conf: improve logging configuration
- both "error_log()" and "access_log()" now support "syslog:" prefix - "error_log()" supports "stderr" destination - both "error_log()" and "access_log()" now support "off" destination (with minor notes for "error_log()")
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
{%- import 'snip/log.j2mod' as ngx_log -%}
|
||||
|
||||
{# {{ ngx_log.error_log(dest='error.log', level=env.NGX_LOGLEVEL) }} #}
|
||||
{{ ngx_log.error_log(level=env.NGX_LOGLEVEL) }}
|
||||
{%- import 'snip/log.j2mod' as _log -%}
|
||||
{#- {{ _log.error_log(dest='error.log', level=env.NGX_LOGLEVEL) }} -#}
|
||||
{{ _log.error_log(level=env.NGX_LOGLEVEL) }}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
{%- import 'snip/log.j2mod' as ngx_log -%}
|
||||
|
||||
{# {{ ngx_log.access_log(dest='access.log', format='main') }} #}
|
||||
{{ ngx_log.access_log(format='main') }}
|
||||
{%- import 'snip/log.j2mod' as _log -%}
|
||||
{#- {{ _log.access_log(dest='access.log', format='main') }} -#}
|
||||
{{ _log.access_log(format='main') }}
|
||||
|
@@ -1,12 +1,35 @@
|
||||
{%- macro error_log(dest='error.log', level='warn') %}
|
||||
error_log {{ '/run/ngx/log'|join_prefix(dest) | ngx_esc }} {{ level | ngx_esc }};
|
||||
{%- endmacro %}
|
||||
{% macro error_log(dest='error.log', level='warn') %}
|
||||
{%- if dest == 'off' %}
|
||||
## not a really disabled log but quiet as less as possible
|
||||
error_log stderr emerg;
|
||||
{%- else %}
|
||||
error_log
|
||||
{%- if dest == 'stderr' %}
|
||||
{{ dest }}
|
||||
{%- elif dest.startswith('syslog:') %}
|
||||
{{ dest | ngx_esc }}
|
||||
{%- else %}
|
||||
{{ join_prefix('/run/ngx/log', dest) | ngx_esc }}
|
||||
{%- endif %}
|
||||
{{ level | ngx_esc }};
|
||||
{%- endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{%- macro access_log(dest='access.log', format='main') %}
|
||||
access_log {{ '/run/ngx/log'|join_prefix(dest) | ngx_esc }} {{ format | ngx_esc }}
|
||||
{% macro access_log(dest='access.log', format='main') %}
|
||||
{%- if dest == 'off' %}
|
||||
access_log off;
|
||||
{%- else %}
|
||||
access_log
|
||||
{%- if dest.startswith('syslog:') %}
|
||||
{{ dest | ngx_esc }}
|
||||
{%- else %}
|
||||
{{ join_prefix('/run/ngx/log', dest) | ngx_esc }}
|
||||
{%- endif %}
|
||||
{{ format | ngx_esc }}
|
||||
{%- for k, v in kwargs|dictsort %}
|
||||
{{ "{}={}".format(k, v) | ngx_esc }}
|
||||
{%- endfor %}
|
||||
;
|
||||
{%- endmacro %}
|
||||
{%- endif %}
|
||||
{% endmacro %}
|
||||
|
Reference in New Issue
Block a user