Search code examples
perlloggingplackpsgi

How can Plack applications log to multiple loggers?


Plack Middleware is very useful, for instance to configure logging targets independent of the application. But I have not found a method to use multiple loggers at the same time:

my $app = MyApp->new();

builder {
  enable 'ConsoleLogger'; # show in Client's console
  enable 'SimpleLogger';  # show on STDERR
  $app;
}

With this configuration 'SimpleLogger' is muted by 'ConsoleLogger', but I want to log by both at the same time.


Solution

  • As of this writing you can't. I've been thinking about having a new logger middleware that acts as a sort of proxy, to dispatch logging to multiple middleware, but haven't got any tuit to write one.