简体   繁体   中英

Unable to write Silverstripe 4 error log to email

I have put these codes to .yml file and I am still not getting emails with errors

SilverStripe\Core\Injector\Injector:
    Psr\Log\LoggerInterface:
      calls:
        MailHandler: [ pushHandler, [ '%$MailHandler' ] ]
    MailHandler:
      class: Monolog\Handler\NativeMailerHandler
      constructor:
        - abc@sss.com
        - There was an error on your test site
        - abc@sss.com
        - error
      properties:
        ContentType: text/html
        Formatter: %$SilverStripe\Logging\DetailedErrorFormatter

You haven't mentioned which version of Silverstripe 4 you're using, so I'll assume it's one of the latest minor releases.

Since 4.4.0 (I think) Silverstripe does not write to the default LoggerInterface handler for core error handling, allowing you to use it for custom app logging instead. If you're a version from 4.4 onwards, and you want to send application errors to your mail handler, you will need to use the Psr\\Log\\LoggerInterface.errorhandler instance instead:

SilverStripe\Core\Injector\Injector:
  Psr\Log\LoggerInterface.errorhandler:
    ...    

You should also ensure that you've correctly configured your email driver .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM