Several handlers work fine for me but the configuration for SwiftMailer presents an obstacle I've yet to solve. Local mail delivery works fine but when I want to define the mailer arguments I'm unable to configure it correctly.
monolog.handler.myhandler:
class: \Monolog\Handler\SwiftMailerHandler
arguments:
mailer:
class: Swift_Mailer
transport:
class: Swift_SmtpTransport
host: '192.168.0.1'
port: 25
message: 'Example'
level: DEBUG
I've tried various variants of this, such as absolute class names like \Swift_Mailer and or the arguments wrapped in array instead of as named attributes but the best I've received until now is mailer being null instead of Swift_Mailer. I think this is a bug in terms of how attributes can be defined here but am leaving it as support request for now, should this be a user error.
The only related issue I've found on this topic is https://github.com/theorchard/monolog-cascade/issues/59
Comment | File | Size | Author |
---|---|---|---|
#5 | monolog-2915422-5.patch | 2.3 KB | lussoluca |
#4 | monolog-2915422-4.patch | 1.67 KB | lussoluca |
Comments
Comment #2
lussolucaServices in Service Container are not configurabile like bundles in a Symfony application.
I think the solution here could be create a new custom handler class, subclassing \Monolog\Handler\SwiftMailerHandler and in the new class __construct() call the parent one with all the needed arguments (maybe reading the arguments from the Configuration Management System).
Comment #3
grahlThanks for your feedback, that helps.
I'll provide an example in this issue when I have that running.
Comment #4
lussolucaThis patch adds a new DrupalMail handler to send a log message by mail.
Comment #5
lussolucaWith updated documentation
Comment #6
rp7 CreditAttribution: rp7 commentedThe provided example (with only modifying the error level) doesn't work with my me:
I did however get it to work like this:
For some reason 'monolog.level.error' is not automatically converted the equivalent number. Is this only on my installation or are other people experiencing this as well?
Comment #7
grahlSorry, never got around to helping in this issue and am not working with Monolog+Swiftmailer at the moment.
Comment #8
lussolucaCould you please try with:
Comment #10
lussolucaCommitted and pushed to 8.x-1.x