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:
[date] [random number] [debug] [random code] POST "/endpoint" [date] [same random number] [debug] [same random code] Routing to a ca +llback
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: request logging with Mojolicious
by haukex (Archbishop) on Oct 12, 2022 at 05:44 UTC | |
by tomgracey (Scribe) on Dec 15, 2022 at 17:30 UTC | |
|
Re: request logging with Mojolicious
by alexander_lunev (Pilgrim) on Oct 12, 2022 at 17:08 UTC | |
by tomgracey (Scribe) on Dec 15, 2022 at 17:34 UTC |