SwiftMailer Logger - Does it work?


There is a Logger class included with SwiftMailer. Has anyone been able to get it to work?

per the comments in the yii\swiftmailer\Logger class, I’ve added this to my application’s components section in the config:

    'log' => [

        'targets' => [


                'class' => 'yii\log\FileTarget',

                'categories' => ['yii\swiftmailer\Logger::add'],

                'logFile' => '@app/runtime/logs/email.log',




but, when I send a message:






The message is sent, but I expect to see a log entry in email.log for this message, but I see nothing - (the email.log log file’s not even created).

If I understand it correctly, the Logger.php class is supposed to output all the Yii::info calls in the Yii Swiftmailer functions. But it’s not doing that.

Has anyone gotten this to work?


Ah - OK, I figured it out.

You need to add:

'enableSwiftMailerLogging' => true,

to your mailer config:

    'components' => [

        'mailer' => [

            'class' => 'yii\swiftmailer\Mailer',

            'enableSwiftMailerLogging' => true,

            'viewPath' => '@app/mail',

            'useFileTransport' => false,

            'transport' => [

                // your transport here