in reply to request logging with Mojolicious

You could write your access logger like this:
sub startup { # ... my $r_begin = $self->routes; my $r = $r_begin->under('' => sub { my $c = shift; my $params = $c->req->params->to_hash; # do your logging here }); # # your endpoints here # # catch-all route at end, your fancy 404 page and also place for log +ging $r->any('/*whatever' => {whatever => ''} => sub { my $c = shift; my $message = 'PAGE 404 '.$c->tx->{original_remote_address}." ".$c +->tx->req->url; $self->app->log->debug($message); # . Dumper($c->tx) $c->render(status => 404, text => $message); }); }

Replies are listed 'Best First'.
Re^2: request logging with Mojolicious
by tomgracey (Scribe) on Dec 15, 2022 at 17:34 UTC

    Thanks for your help with this - and sorry for the (very) late reply. I did solve this with a plugin in the end. Your suggestion does look like a good way to do it without needing a plugin however. Thanks again.