Skip to content
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

Matomo application logs can now be written in syslog and errorlog #17745

Merged
merged 1 commit into from Jul 11, 2021
Merged

Matomo application logs can now be written in syslog and errorlog #17745

merged 1 commit into from Jul 11, 2021

Conversation

mwithheld
Copy link
Contributor

Issue #9400

Description:

Add log handlers syslog and errorlog

Review

  • Functional review done
  • Potential edge cases thought about (behavior of the code with strange input, with strange internal state or possible interactions with other Matomo subsystems)
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

@diosmosis diosmosis added this to the 4.4.0 milestone Jul 11, 2021
@diosmosis
Copy link
Member

Hi @mwithheld, thanks for the contribution! Greatly appreciated.

@diosmosis diosmosis merged commit 288c07e into matomo-org:4.x-dev Jul 11, 2021
diosmosis added a commit that referenced this pull request Jul 11, 2021
diosmosis added a commit that referenced this pull request Jul 11, 2021
@diosmosis
Copy link
Member

Hi @mwithheld, sorry I just merged this then realized it won't work as is. I've left some review comments. Can you create a new PR w/ the changes?

@@ -17,6 +17,8 @@
'file' => 'Piwik\Plugins\Monolog\Handler\FileHandler',
'screen' => 'Piwik\Plugins\Monolog\Handler\WebNotificationHandler',
'database' => 'Piwik\Plugins\Monolog\Handler\DatabaseHandler',
'syslog' => 'Piwik\Plugins\Monolog\Handler\SyslogHandler',
'errorlog' => 'Piwik\Plugins\Monolog\Handler\ErrorLogHandler',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These classes don't exist, they need to match the actual monolog classes, for example, \Monolog\Handler\ErrorLogHandler::class

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same applies for the references below.

@mwithheld
Copy link
Contributor Author

mwithheld commented Jul 13, 2021

That was silly of me - a fix is in PR #17746 along with adding the option to set the syslog ident.

Testing syslog:
In config.ini.php, add to the [log] section:

[log]
; possible values for log: screen, database, file, syslog, errorlog
log_writers[] = syslog

; log level, everything logged w/ this level or one of greater severity
; will be logged. everything else will be ignored. possible values are:
; ERROR, WARN, INFO, DEBUG
; this setting will apply to every log writer, if there is no specific log level defined for a writer.
log_level = DEBUG

; if configured to log to syslog, mark them with this identifier string.
; This acts as an easy-to-find tag in the syslog.
logger_syslog_ident = 'matomo'

Output in syslog looks like this (will vary depending on your syslog config)

2021-07-13T11:49:08.179-07:00 somesystemname syslog.debug matomo[567263]: DEBUG Piwik\Plugin\Manager[2021-07-13 18:49:08 UTC] [2b44b] Loaded plugins: CorePluginsAdmin, CoreAdminHome, ..., TreemapVisualization
2021-07-13T11:49:08.179-07:00 somesystemname syslog.debug matomo[567263]:

Testing errorlog:
In config.ini.php, add to the [log] section:

[log]
; possible values for log: screen, database, file, syslog, errorlog
log_writers[] = errorlog

; log level, everything logged w/ this level or one of greater severity
; will be logged. everything else will be ignored. possible values are:
; ERROR, WARN, INFO, DEBUG
; this setting will apply to every log writer, if there is no specific log level defined for a writer.
log_level = DEBUG

Output in errorlog looks like very similar to the above, depending on your config (without the syslog ident tag).

@mattab mattab changed the title Add log handlers syslog and errorlog Matomo application logs can now be written in syslog and errorlog Jul 27, 2021
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants