Skip to content

Commit

Permalink
Merge pull request #1792 from OpenConext/feature/add-docker-logging-c…
Browse files Browse the repository at this point in the history
…onfig

Make Docker logging to stderr the default
  • Loading branch information
pablothedude authored Feb 11, 2025
2 parents 9d09b65 + 12dad36 commit 32d3834
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 12 additions & 9 deletions app/config/logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
1 change: 0 additions & 1 deletion app/config/parameters.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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%%'

##########################################################################################
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 0 additions & 19 deletions docker/conf/logging.yml

This file was deleted.

2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
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
[filter]: https://github.com/OpenConext/OpenConext-engineblock/tree/master/docs/filter_commands.md
[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
37 changes: 37 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 32d3834

Please sign in to comment.