Change UID for watchdog message In Drupal 8 with DbLog logger, I am trying to log some audit messages to a different user than the currently logged-in user. Unfortunately, it looks like something is overwriting my context.

I tried \Drupal::logger("proreos")-&gt;info("bla", ['uid' =&gt; 5]); and \Drupal::logger("proreos")-&gt;info("bla", ['user' =&gt; User::load(5)]);, but neither of them worked. In both the cases, the current user ID was instead used.

How can I use a different user ID?

To clarify: This is not about logging another uid, it is about assigning the row in watchdog to a different user.
Logger will always log for the current user, except you provide your own logging service.

The context is used to replace placeholders in the message, see here, so to get the userid in the message, use this:

\Drupal::logger("proreos")-&gt;info("bla @uid", array('@uid' =&gt; 5));