Skip to content

Commit

Permalink
Make Docker logging to stderr the default
Browse files Browse the repository at this point in the history
This will make logging to stderr the default.
Also documentation is added on how to add syslog config.
This will allow debugging in dev env (devonf) out-of-the-box.
  • Loading branch information
pablothedude committed Feb 6, 2025
1 parent c72e17a commit 7ce7a13
Show file tree
Hide file tree
Showing 7 changed files with 54 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 @@ -113,7 +113,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
38 changes: 38 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 to the Monolog 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 7ce7a13

Please sign in to comment.