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!


In reply to request logging with Mojolicious by tomgracey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.