Created
May 13, 2021 22:24
-
-
Save tamert/11af056b5bf81536216a045bec4e0a2c to your computer and use it in GitHub Desktop.
Symfony + Sentry + Monolog - Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
monolog: | |
channels: [ sentry, update, userImport, updateLicenseByLicenseServer ] | |
handlers: | |
update: | |
type: service | |
id: Sentry\Monolog\Handler | |
channels: [ update ] | |
path: "%kernel.logs_dir%/licenseUpdate.log" | |
userImport: | |
type: service | |
id: Sentry\Monolog\Handler | |
channels: [ userImport ] | |
path: "%kernel.logs_dir%/userImport.log" | |
updateLicenseByLicenseServer: | |
type: service | |
id: Sentry\Monolog\Handler | |
channels: [ updateLicenseByLicenseServer ] | |
path: "%kernel.logs_dir%/updateLicenseByLicenseServer.log" | |
sentry: | |
type: service | |
id: Sentry\Monolog\Handler | |
main: | |
path: "%kernel.logs_dir%/%kernel.environment%.log" | |
type: stream | |
level: debug | |
channels: [ "!event" ] | |
console: | |
type: console | |
process_psr_3_messages: false | |
channels: [ "!event", "!doctrine", "!console" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Command; | |
use Psr\Log\LoggerInterface; | |
use Symfony\Component\Console\Input\InputInterface; | |
use Symfony\Component\Console\Output\OutputInterface; | |
use Symfony\Component\Console\Command\Command; | |
class MonologTest extends Command | |
{ | |
protected static $defaultName = 'monolog:test'; | |
private $updateLicenseByLicenseServerLogger; | |
public function __construct( | |
LoggerInterface $updateLicenseByLicenseServerLogger | |
) | |
{ | |
$this->updateLicenseByLicenseServerLogger = $updateLicenseByLicenseServerLogger; | |
parent::__construct(); | |
} | |
protected function execute(InputInterface $input, OutputInterface $output) | |
{ | |
$this->updateLicenseByLicenseServerLogger->error("test mesajıdır aga !"); | |
return 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentry: | |
dsn: '%env(SENTRY_DSN)%' | |
register_error_listener: false | |
options: | |
excluded_exceptions: | |
- 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' | |
- 'Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException' | |
- 'Symfony\Component\Security\Core\Exception\AccessDeniedException' | |
- 'Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException' | |
- 'Lexik\Bundle\JWTAuthenticationBundle\Exception\JWTDecodeFailureException' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
Sentry\Monolog\Handler: | |
arguments: | |
$hub: '@Sentry\State\HubInterface' | |
$level: !php/const Monolog\Logger::ERROR | |
Monolog\Processor\PsrLogMessageProcessor: | |
tags: { name: monolog.processor, handler: sentry } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment