Severities should not be translated in logs

Created on 21 March 2024, 8 months ago

Problem/Motivation

On a multilingual site we noticed that the logged messages use the translated severity. So for us some messages are logged as "[ERROR]" on the English page and as "[FEHLER]" on the German translation. This makes searching the logs for a specific log severity hard, especially with many languages.

Steps to reproduce

  • Setup Drupal with the standard profile.
  • Install the modules log_stdout and locale.
  • Add a new language at /admin/config/regional/language and set it as the default language.
  • Trigger a message that gets logged to the Watchdog (\Drupal::logger()). Make sure that the severity is actually translated for the installed language.

Example

To test it I added German as a new language and added \Drupal::logger('test')->warning('test') to Drupal\log_stdout\Form\LogStdoutConfigForm::buildForm(). After visiting /admin/config/development/log_stdout you can see something like ...[WARNUNG] [test] [2024-03-21T11:15:30] test | uid: 1... in the StdOut. When using DDEV you can use ddev logs -f to see the container output.

Proposed resolution

Use the untranslated severity.

📌 Task
Status

RTBC

Version

1.5

Component

Code

Created by

🇩🇪Germany manuelbitmade

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024