Last active
May 9, 2024 01:50
-
-
Save timkelty/186dad653e72b42eb1401c559881bb39 to your computer and use it in GitHub Desktop.
Craft 5 Logging Example
This file contains hidden or 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 | |
use craft\helpers\App; | |
return [ | |
'id' => App::env('CRAFT_APP_ID') ?: 'CraftCMS', | |
'components' => [ | |
'log' => [ | |
'targets' => [ | |
function() { | |
// @see https://craftcms.com/docs/5.x/system/logging.html#targets for filtering options | |
$target = new \craft\log\MonologTarget([ | |
'name' => 'azure-blob', | |
]); | |
$connection = 'DefaultEndpointsProtocol=https;AccountName=<name>;AccountKey=<key>'; | |
$client = \MicrosoftAzure\Storage\Blob\BlobRestProxy::createBlobService($connection); | |
$handler = \Blue32a\Monolog\Handler\AzureBlobStorageHandler($client, 'container', 'append-blob.log'); | |
$target->getLogger()->setHandlers([$handler]); | |
return $target; | |
}, | |
] | |
] | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment