8 – How can I output log messages to stdout/stderr?


I can create log messages really easily in Drupal 9.x like this;

Drupal::logger('mymodule')->error("something went wrong");

I see these messages appear in /admin/reports/dblog, but it would be convenient if I had the option to print them to stdout, or perhaps a file that I could tail. Is this possible?

Note that this question looks similar but I think it’s for an older version of drupal using watchdog, so I don’t think it applies: how to show admin/reports/dblog in terminal ( cli )