Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7] Allow predefined log channels to change formatter from config #26895

Conversation

troccoli
Copy link
Contributor

This PR is about the ability to specify a formatter from the config file for the single, daily and syslog driver.

The default formatter, the LineFormatter, print the date and time, channel name, level and text for every message logged. To change the format of the message, for example to remove the channel name, or to use a different formatter, for example the HtmlFormatter, you have to use the monolog driver with the correct handler.

Compare the following configurations:

return [
    "channels" => [
        "formatted_single" => [
            "driver" => "monolog",
            "handler" => StreamHandler::class
            "handler_with" => [
                "stream" => storage_path("logs/laravel.log"),
                "level" => "info",
            ],
            "formatter" => LineFormatter::class,
            "formatter_with" => [
                "format" => "[%datetime%] %level_name%: %message%",
            ],
        ]
    ]
]

and

return [
    "channels" => [
        "formatted_single" => [
            "driver" => "single",
            "path" => storage_path("logs/laravel.log"),
            "level" => "info",
            "formatter" => LineFormatter::class,
            "formatter_with" => [
                "format" => "[%datetime%] %level_name%: %message%",
            ],
        ]
    ]
]

@troccoli troccoli force-pushed the allow-predefined-log-channels-to-change-formatter-from-config branch from 3cb2721 to f2fe2de Compare December 19, 2018 09:56
@troccoli troccoli force-pushed the allow-predefined-log-channels-to-change-formatter-from-config branch from f2fe2de to 4e49e7d Compare December 19, 2018 09:57
@taylorotwell taylorotwell merged commit b714370 into laravel:5.7 Dec 19, 2018
@troccoli troccoli deleted the allow-predefined-log-channels-to-change-formatter-from-config branch December 19, 2018 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants