4

In our Drupal 8 - CiviCRM we use Redis for caching and some log management. We would like that CiviCRM also logs errors to Redis, or any other log system for that matter. Is it possible to configure/swap the log classes as is possible with cache classes?

In civicrm-core/packages/Log I see there are other classes available for logging but I don't know how they are used. How would a syslog for example be used for error logs?

Is it at all possible to use a different class for error logs or has this functionality yet to be build?

0

You'd have to write your own but under Administer -> System Settings -> Debugging and Error Handling you can set a classname that will handle fatal errors. However this only handles fatal errors.

Another method is to override the CRM/Core/Error.php class. The docs don't seem to exist anymore or at least I can't find them, and I don't see it in the extensions documentation either but I think you can do this with an extension, but you can do it standalone by going to Administer -> System Settings -> Directories and specify a custom php directory, and then create a CRM/Core/Error.php under that folder (can copy the original file). Then edit that new file.

The Log folder under packages I think is just a dependency of some of the 3rd party packages. I don't think core uses it.

  • 3
    Thanks @Demerit for your answer! Based on the info and insights you have given me I started building an extension: github.com/wannesderoy/be.calibrate.eavesdropper. Right now it's a very basic implementation, but it works well. – Wannes De Roy Aug 9 '18 at 18:36
  • Great! I'm sure others will also find the extension useful. – Demerit Aug 9 '18 at 21:24
  • 1
    I did'n override the Error.php as you mentioned, but the Log.php file instead. This looked like a much simpeler class to override and maintain. And all the logs pass through there with all the necessary data to stick them in Redis. – Wannes De Roy Aug 10 '18 at 6:40
4

I created an extension that writes all the logs to Redis: https://civicrm.org/extensions/eavesdropper Issues, questions or feature requests can be added on github.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.