Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: request logging with Mojolicious

by alexander_lunev (Pilgrim)
on Oct 12, 2022 at 17:08 UTC ( [id://11147375]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147375]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-28 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found