[dancer-users] Access logging in Dancer

Matthew Mallard matt at Q-technologies.com.au
Tue Jun 2 12:31:56 BST 2015


Hi,

I’m trying to do some custom access logging in Dancer2.  I note that plackup does the access logging (--access-log) and the man page for Plack::Middleware::AccessLog says that the format can be modified in the app.psgi file:

# in app.psgi
use Plack::Builder;
  builder {
      enable "Plack::Middleware::AccessLog", format => "combined";
      $app;
};

I tried something similar in app.pl, but it kind of works, but doesn’t fully replace the existing access logging.  That is:
  * the log file specified with --access-log remains unchanged - i.e. it keeps getting written to in ‘combined’ format
  * the new format specified gets written to STDERR (i.e. the location specified with --error-log (for plackup)

Here’s the config I’m using:
use Plack::Builder;
use mymod::api;
builder {
    enable "AccessLog",
        format => '%h %l %u %t "%r" %>s %b "%{User-agent}i" "%{content-type}i';
    mount '/api' => mymod::api->to_app;
};

Any ideas on how I can get it to overwrite the default access logging?

Thanks,
Matt


More information about the dancer-users mailing list