Last Updated: February 25, 2016
·
739
· hashbangperl

Custom fields in Plack AccessLog middleware

https://metacpan.org/pod/Plack::Middleware::AccessLog provides a quick easy way to record Apache style logs, and one of the benefits of that is that you can specify custom fields that it can log using the format.

By specifying

"... %{Foo-bar}i .."

in the log format, you can populate the fields in each request by setting

$request->env->{FOO_BAR} = $foo;

Where $request is the Plack::Request object