diff --git a/app/config/config_test.yml b/app/config/config_test.yml index 8fff176bb..b9f71ffbd 100644 --- a/app/config/config_test.yml +++ b/app/config/config_test.yml @@ -47,9 +47,9 @@ monolog: type: fingers_crossed activation_strategy: engineblock.logger.manual_or_error_activation_strategy passthru_level: "%logger.fingers_crossed.passthru_level%" - handler: file + handler: nested channels: ['!event'] - file: + nested: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: DEBUG diff --git a/app/config/logging.yml b/app/config/logging.yml index 8a4e1d5aa..9c70f6e3e 100644 --- a/app/config/logging.yml +++ b/app/config/logging.yml @@ -5,16 +5,19 @@ monolog: type: fingers_crossed activation_strategy: engineblock.logger.manual_or_error_activation_strategy passthru_level: "%logger.fingers_crossed.passthru_level%" - handler: syslog - channels: ["!authentication"] - syslog: - type: syslog - ident: "%logger.syslog.ident%" - formatter: engineblock.logger.additional_info_formatter + handler: nested + channels: [!authentication] + nested: + type: stream + path: php://stderr + formatter: engineblock.logger.formatter.syslog_json authentication: - type: syslog - ident: EBAUTH - facility: user + type: stream + path: php://stderr level: INFO channels: [authentication] formatter: engineblock.logger.formatter.syslog_json + console: + type: console + process_psr_3_messages: false + channels: [!event, !doctrine, !console] diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 2687881fc..dc351d53b 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -119,7 +119,6 @@ parameters: logger.channel: engineblock logger.fingers_crossed.passthru_level: NOTICE logger.fingers_crossed.action_level: ERROR - logger.syslog.ident: EBLOG logger.line_format: '[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%extra%% %%context%%' ########################################################################################## diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod index e97f4d7ab..be2304bff 100644 --- a/docker/Dockerfile.prod +++ b/docker/Dockerfile.prod @@ -13,7 +13,6 @@ RUN tar -xvjf /tmp/*.tar.bz2 -C /var/www/html/ && \ # Add the config files for Apache2 RUN rm -rf /etc/apache2/sites-enabled/* COPY ./docker/conf/engine.conf /etc/apache2/sites-enabled/engine.conf -COPY ./docker/conf/logging.yml /var/www/html/app/config/logging.yml # Instantiate devconf config RUN cp app/config/parameters.yml.dist app/config/parameters.yml diff --git a/docker/conf/logging.yml b/docker/conf/logging.yml deleted file mode 100644 index b258eac5a..000000000 --- a/docker/conf/logging.yml +++ /dev/null @@ -1,19 +0,0 @@ -monolog: - channels: ["%logger.channel%", "authentication"] - handlers: - main: - type: fingers_crossed - activation_strategy: engineblock.logger.manual_or_error_activation_strategy - passthru_level: "%logger.fingers_crossed.passthru_level%" - channels: [!authentication] - handler: stderr - authentication: - type: stream - path: php://stderr - level: INFO - channels: [authentication] - formatter: engineblock.logger.formatter.syslog_json - stderr: - type: stream - path: php://stderr - formatter: engineblock.logger.formatter.syslog_json diff --git a/docs/index.md b/docs/index.md index 6e019c180..bcb30a928 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,6 +9,7 @@ 1. [Release notes for releases < 5.0.0][release-notes] 1. [PHP testing][php-testing] 1. [Javscript testing][js-testing] +1. [Logging][logging] [license]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/LICENSE [release]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/release_procedure.md @@ -16,3 +17,4 @@ [release-notes]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/release_notes [php-testing]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/php_testing.md [js-testing]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/js_testing.md +[logging]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/logging.md diff --git a/docs/logging.md b/docs/logging.md new file mode 100644 index 000000000..3096c279d --- /dev/null +++ b/docs/logging.md @@ -0,0 +1,37 @@ +# Logging + +## Overview + +The default logging method of Engineblock is logging to `stderr`, which is particularly useful for Docker-based deployments. +However, logging to `syslog` will still be possible for environments where traditional syslog logging is required. + +## Configuring Logging to Syslog + +To configure `logging.yml` to log to syslog, you should use the syslog handler in the logging configuration. +Below is an example configuration: + +```yaml +monolog: + channels: ["%logger.channel%", "authentication"] + handlers: + main: + type: fingers_crossed + activation_strategy: engineblock.logger.manual_or_error_activation_strategy + passthru_level: "%logger.fingers_crossed.passthru_level%" + channels: [!authentication] + handler: nested + authentication: + type: syslog + ident: EBAUTH + facility: user + level: INFO + channels: [authentication] + formatter: engineblock.logger.formatter.syslog_json + nested: + type: syslog + ident: "EBLOG" + formatter: engineblock.logger.formatter.syslog_json` + console: + type: console + process_psr_3_messages: false + channels: [!event, !doctrine, !console]