This Shopware 6 Plugin creates log files with file rotation, max file size setup, loglevels, etc. You can create for all your plugins own log fieles by context. like /var/log/myloginplugin.vendor.log, or /var/log/myextraplugin.vendor.log It can send emails by log events. For example: You get an error log event, and it can sends an email to a specific address.
- Works for alle Shopware 6 versions, 6.5.x or greater
- Create log files with automatic file rotation by max file size and max file count
- Log files can automatically compress by gzip
- Easy to use logger interface, which can be used in all plugins and creates own log files by context
- Global log setup via plugin configuration, like log level, pattern for log content format, etc.

- Can send emails by log events
- Storefront errors can be idendified by a unique error id, which can be used to find the error in the log file

composer require muckiware/log-plugin
bin/console plugin:install -a MuckiLogPluginIn order not to create dependencies from Muckilog to other plugins, the original Monolog interface can be used. Muckilog plugin will replace the monolog method by using a decorator.
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="YourPlugin\Storefront\Pagelet\Header\Subscriber\YourHeaderPageSubscriber">
...
<argument type="service" id="Psr\Log\LoggerInterface"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</container><?php
declare(strict_types=1);
namespace YourPlugin\Storefront\Pagelet\Header\Subscriber;
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\Struct\ArrayEntity;
use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Psr\Log\LoggerInterface;
/**
* Class YourHeaderPageSubscriber
*/
class YourHeaderPageSubscriber implements EventSubscriberInterface
{
public function __construct(
...
protected LoggerInterface $logger
) {
...
$this->logger = $logger;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
// Subscribing to HeaderPageLetLoadedEvent
HeaderPageletLoadedEvent::class => 'HeaderPageletLoadedEvent',
];
}
/**
* @param HeaderPageletLoadedEvent $event
*/
public function HeaderPageletLoadedEvent(HeaderPageletLoadedEvent $event): void
{
$this->logger->debug('Call HeaderPageEvent', array('myplugin', 'vendor'));
...
$this->logger->info('debug', 'Call HeaderPageEvent', array('myplugin', 'vendor'));
}
}You have these kind of log levels
//Regular logger usage
$this->logger->debug('Call HeaderPageletLoadedEvent', array('myplugin', 'vendor'));
$this->logger->info('Call HeaderPageletLoadedEvent', array('myplugin', 'vendor'));
$this->logger->warning('Call HeaderPageletLoadedEvent', array('myplugin', 'vendor'));
$this->logger->error('Call HeaderPageletLoadedEvent', array('myplugin', 'vendor'));
$this->logger->critical('Call HeaderPageletLoadedEvent', array('myplugin', 'vendor'));
//logger with context setup object usage
$loggerContext = array(
'myplugin',
'vendor',
array('setup' =>
array(
'notificationEmail' => true,
'notificationEmailReceiver' => 'notificationEmailReceiver@example.com',
'notificationEmailSender' => 'notificationEmailSender@example.com',
)
)
);
$this->logger->critical('Call HeaderPageletLoadedEvent with mail notification', $loggerContext);bin/console muckiware:logger:sendThis command execute the sending of open logger events by email. Regular will this execution runs by Shopware schedules all 600 seconds.
bin/console muckiware:logger:checkThis command is just for testing logging methods.
Install phpstan, if required
cd custom/plugin/MuckiLogPlugin
composer installcd custom/plugins/MuckiLogPlugin
composer run-script phpstan./vendor/bin/phpunit --configuration="custom/plugins/MuckiLogPlugin" --testsuite "migration"./vendor/bin/phpunit --configuration="custom/plugins/MuckiLogPlugin"