swiftmailer - How to use php monolog -
i've heard lot monolog(https://github.com/seldaek/monolog) & trying utilize in 1 of our app. but, can't able fig. out how utilize that. don't know it's i'm can't able documentation of or has no documentation @ all.
we want log our errors in db & send email notification error when it'll generate. sending email using swiftmailer(swiftmailer.org).
i can able run sample code github link,
<?php utilize monolog\logger; utilize monolog\handler\streamhandler; // create log channel $log = new logger('name'); $log->pushhandler(new streamhandler('path/to/your.log', logger::warning)); // add together records log $log->addwarning('foo'); $log->adderror('bar');
but can't able understand how utilize db & other email library.
you posted illustration yourself. instead of streamhandler utilize 1 or more of other handlers monolog offering.
you have code of handlers see dependencies need. within monolog directory , you'll find handler classes. code reliable documentation.
<?php utilize monolog\logger; utilize monolog\handler\swiftmailerhandler; utilize swift_mailer; // ... more dependencies need // create swift_mailer , swift_message instances $handlers = [ new swiftmailerhandler($swiftmailer, $swiftmessage), // add together more handler need ]; $log = new logger('name', $handlers); $log->warning('foo'); $log->error('bar');
you have create swift_mailer , swift_message instance swiftmailerhandler. instead of pushhandler, can add together array of handlers logger constructor.
the swift_message instance used every log message message replaces every time mail service body.
i can suggest read monolog code info farther documentation missing.
php swiftmailer monolog
No comments:
Post a Comment