New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the request hostname to error & exception logs #18996
Conversation
This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers |
…' into D2584-add-hostname-to-error-logs
@samjf This looks good so far. Is it on purpose that only exceptions / errors that might get logged outside of matomo's logging will be prefixed with the host? Messages logged to the matomo log files won't include the hostname. For that guess it would need to be added somewhere in https://github.com/matomo-org/matomo/blob/115527353a9e75e01aa4d263408956ae45403bea/plugins/Monolog/Formatter/LineMessageFormatter.php |
@sgiehl I don't think I've really had a problem with the matomo file log. Correct me if i'm wrong but It seems that the hostnames are being logged for me (checking locally). Perhaps archiving/commands already adds them on a multitenant? The main problem was trying to distinguish between a large amount of errors on the PHP/FPM error/exception logging. |
@samjf Guess our cloud plugin has a special log processor, that adds the instanceid. We could consider having that in core and only log it for multitenant maybe. |
Many thanks @sgiehl |
Ref: DEV-2584
Description:
When viewing the logs of a multi-tenant install it is difficult to determine which Matomo instance was requested when the error (log entry) occurs.
A simple solution is to print the host from the incoming headers. Whilst this is not safe against tampering, it is only printed in logs and will be effective for normal traffic.
Notes
I preferred injecting the error message prefix when providing the prefix in
core/testMinimumPhpVersion.php
due to the fact that the code seems to be early in the bootstrap and must be compatible with early versions of PHP. Thefilter_var
validation function of the hostname/domain has a minimum php requirement of 5.2.Review