roadrunner-server / roadrunner-plugins

📦 Home for the roadrunner plugins
MIT License
25 stars 9 forks source link

[FEATURE REQUEST] Access logs #34

Closed cidious closed 3 years ago

cidious commented 3 years ago

The problem is I can't find the access logs when running RR as a frontend web server for PHP Laravel app.

When running the app as Nginx+PHP-FPM you got the access logs from nginx plus slow logs from FPM. Both of them can be routed to stderr inside a container and caught for analysis.

I see the two options to get the logs using RR:

Is it possible to output the access logs by RR in production env?

rustatian commented 3 years ago

Hey @cidious. You can set the log level to a different than the debug mode. Have you tried the other options: https://github.com/spiral/roadrunner-binary/blob/master/.rr.yaml#L66 ?

cidious commented 3 years ago

@rustatian thanks for the answer. I can't find any access logs in any log level except the debug one. Tried info, warn, error, panic -- no result. Even the debug level doesn't have such data as Referer or User-agent and I can't find the option to turn it on.

# rr -v
rr version 2.3.3 (build time: 2021-07-14T15:28:46+0000, go1.16.6)
rustatian commented 3 years ago

@cidious Ok, thanks. Could you please give me the link with the list of entities that should be logged (some documentation)? And I'll try to cover these places. Also, debug logs will slow down your app, but not much (except you have a low-latency system with high RPS (more than 10k RPS)). At the moment you can use production mode with the debug level.

cidious commented 3 years ago

@rustatian The best log format for production is JSON. Sample nginx usage: [1] [2] Official documentation: [link]

As for me, I need the fields: remote_addr, http_host, request, time_local, request_length, request_time, status, bytes_sent, http_user_agent, http_referer

Also it would be nice if RR could collect the slow logs like PHP-FPM does: [1] [2] I'm not sure if it's possible to output the PHP backtrace, but it would be really useful feature.

rustatian commented 3 years ago

Great, thanks @cidious. I'll add these log fields as info (default production loglevel). I'll also discuss this feature with our PHP team and return back to you soon 😃

rustatian commented 3 years ago

@cidious Feature accepted and planned for the current sprint https://github.com/orgs/spiral/projects/2.

rustatian commented 3 years ago

@cidious Feature will be available by the end of the week in the v2.5.0-beta.2 with the following fields: method - http method. remote_addr - request remote address. bytes_sent - content-length, http_host - host. request - request Query. time_local - local time in Common Log Format. request_length - request body with headers size (content-len + size of all headers) in bytes. Max allowed headers size for the RR is 1MB. request_time - request processing time in seconds with a milliseconds resolution. status - http response status. http_user_agent - http user agent http_referer - http referer

rustatian commented 3 years ago

@cidious Please, test the v2.5.0-beta.2: https://github.com/spiral/roadrunner-binary/releases/tag/v2.5.0-beta.2