Welcome to the Monastery | |
PerlMonks |
request logging with Mojoliciousby tomgracey (Scribe) |
on Oct 11, 2022 at 16:30 UTC ( [id://11147348]=perlquestion: print w/replies, xml ) | Need Help?? |
tomgracey has asked for the wisdom of the Perl Monks concerning the following question: Hello Monks I have a Mojolicious API which previously was running via apache, but I recently switched it to hypnotoad due to a memory leak issue. It is a lot happier running with hypnotoad. However, I was used to the comprehensive apache logs. I am sure hypnotoad/mojolicious can also do a decent job with request logs - but I am struggling to find much in the way of documentation (though I maybe looking in the wrong place). I have added $self->log( Mojo::Log->new( path => $log_path, level => $log_level )); in startup and out of the box this seems to produce log lines as follows:
and that's all. The problem is I want to log the full details of the request - ie including the parameters. Now I realise that $self->log can be called inside a route to explicitly log something, and so I could catch the params there and $self->log at that point. However, that way if e.g. a request comes in that doesn't even match any of the registered routes it won't get logged. I am wondering if there is some way to get Mojolicious to include the parameters alongside the POST "/endpoint" line? Alternatively, perhaps I am barking up the wrong tree expecting Mojolicious to do this job - after all it is global logging I'm after and Mojolicious is a framework not a webserver. Can hypnotoad do the logging independently? Again struggling to find any info on this. Any pointers in the right direction would be gladly received.... thanks!
Back to
Seekers of Perl Wisdom
|
|