Skip to content

[4.x] How to register additional log targets files? #11079

Answered by timkelty
MoritzLost asked this question in Q&A
Discussion options

You must be logged in to vote

@MoritzLost While we are working up updated the docs for this, here's some quick and dirty examples: https://gist.github.com/timkelty/c0530983c3fb450c15a5f136fb388d3d

For you, it would look something like this:

  • First, we use monologTargetConfig to filter out any custom-module messages.
  • Then we add a new log target, scoped specifically to custom-module.
    • You can add a traditional Yii file target (first example)
    • …or you can add a Monolog target (second example, recommended)
<?php

use craft\helpers\App;
use Monolog\Formatter\LineFormatter;
use Psr\Log\LogLevel;
use yii\i18n\PhpMessageSource;
use yii\web\HttpException;

return [
    'components' => [
        'log' => [
            'monol…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@MoritzLost
Comment options

@MoritzLost
Comment options

@mattstein
Comment options

@timkelty
Comment options

Comment options

You must be logged in to vote
1 reply
@MoritzLost
Comment options

Answer selected by brandonkelly
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants