PHPackages                             gcrico/swift-mailer-psr-logger-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. gcrico/swift-mailer-psr-logger-plugin

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

gcrico/swift-mailer-psr-logger-plugin
=====================================

Logs swift mailer activity with a (PSR-3) logger.

v1.2.0(7y ago)746.3k↓100%2MITPHP

Since Jun 13Pushed 7y ago2 watchersCompare

[ Source](https://github.com/gcrico/swift-mailer-psr-logger-plugin)[ Packagist](https://packagist.org/packages/gcrico/swift-mailer-psr-logger-plugin)[ Docs](https://github.com/gcrico/swift-mailer-psr-logger-plugin)[ RSS](/packages/gcrico-swift-mailer-psr-logger-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

swift-mailer-psr-logger-plugin
==============================

[](#swift-mailer-psr-logger-plugin)

Logs swift mailer activity with a (PSR-3) logger.

There are [several psr/log implementations](https://packagist.org/search/?q=psr/log) out there.

**Warning!** The logger must NOT send emails with a mailer that it is logging, or you will run in a dead loop!

Installation
------------

[](#installation)

```
php composer.phar require gcrico/swift-mailer-psr-logger-plugin @stable
```

Example Usage
-------------

[](#example-usage)

This will log all the mailer activity:

```
use gcrico\SwiftMailerPsrLoggerPlugin\SwiftMailerPsrLoggerPlugin;

$transport = /*...*/;
$mailer = Swift_Mailer::newInstance($transport);

$logger = new YourFavoritePsr3Logger();
$mailer_logger = new SwiftMailerPsrLoggerPlugin($logger);
$mailer->registerPlugin($mailer_logger);
```

The default log levels are:

```
    'sendPerformed.SUCCESS'     => LogLevel::INFO,
    'sendPerformed.TENTATIVE'   => LogLevel::WARNING,
    'sendPerformed.NOT_SUCCESS' => LogLevel::ERROR,
    'sendPerformed.PENDING'     => LogLevel::DEBUG,
    'sendPerformed.SPOOLED'     => LogLevel::DEBUG,
    'exceptionThrown'           => LogLevel::ERROR,
    'beforeSendPerformed'       => LogLevel::DEBUG,
    'commandSent'               => LogLevel::DEBUG,
    'responseReceived'          => LogLevel::DEBUG,
    'beforeTransportStarted'    => LogLevel::DEBUG,
    'transportStarted'          => LogLevel::DEBUG,
    'beforeTransportStopped'    => LogLevel::DEBUG,
    'transportStopped'          => LogLevel::DEBUG,
```

You can change the default log levels:

```
$mailer_log_levels =  array(
    'sendPerformed.SUCCESS'     => LogLevel::DEBUG,
    'sendPerformed.NOT_SUCCESS' => LogLevel::WARNING,
    'exceptionThrown'           => LogLevel::WARNING,
);
$mailer_logger = new SwiftMailerPsrLoggerPlugin($logger, $mailer_log_levels);
```

You can disable logging of some events, using a falsy value for the level.

```
$mailer_log_levels =  array(
    'commandSent'               => 0,
    'sendPerformed.NOT_SUCCESS' => false,
    'exceptionThrown'           => null,
    'beforeTransportStopped'    => '',
);
$mailer_logger = new SwiftMailerPsrLoggerPlugin($logger, $mailer_log_levels);
```

Example Usage with Silex
------------------------

[](#example-usage-with-silex)

This workaround is needed for Silex &lt;= 1.2.0 (see [silexphp/Silex#959](https://github.com/silexphp/Silex/issues/959)):

```
$app['swiftmailer.spooltransport'] = $app->share(function ($app) {
    return new \Swift_Transport_SpoolTransport($app['swiftmailer.transport.eventdispatcher'], $app['swiftmailer.spool']);
});
```

Let's extends the mailer service:

```
use gcrico\SwiftMailerPsrLoggerPlugin\SwiftMailerPsrLoggerPlugin;

$app->extend('mailer', function ($mailer) use ($app) {
    $app_logger = $app['logger'];
    $mailer_logger = new SwiftMailerPsrLoggerPlugin($app_logger);
    $mailer->registerPlugin($mailer_logger);
    return $mailer;
});
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~580 days

Total

4

Last Release

2611d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c7267fa9d5e7cd22b3b5acff2b0dc04f121f67318358365fd2b6a63e3d5b277?d=identicon)[gcrico](/maintainers/gcrico)

---

Top Contributors

[![gcrico](https://avatars.githubusercontent.com/u/159873?v=4)](https://github.com/gcrico "gcrico (8 commits)")[![venimus](https://avatars.githubusercontent.com/u/632282?v=4)](https://github.com/venimus "venimus (3 commits)")[![cricog](https://avatars.githubusercontent.com/u/10711196?v=4)](https://github.com/cricog "cricog (1 commits)")

---

Tags

psrlogloggingmailerswiftswiftmailer

### Embed Badge

![Health badge](/badges/gcrico-swift-mailer-psr-logger-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/gcrico-swift-mailer-psr-logger-plugin/health.svg)](https://phpackages.com/packages/gcrico-swift-mailer-psr-logger-plugin)
```

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[league/tactician-logger

Adds PSR-3 logging support to the Tactician command bus

649.6M9](/packages/league-tactician-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
