mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-27 08:35:53 +03:00
[GH-ISSUE #800] Separating messages of various log-levels into different files? #304
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#304
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rkulagowski on GitHub (May 28, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/800
Within my code, I'm trying to get multiple files, each that only has log messages of a particular significance, so that when it comes time to check for logs I know that each file will only have a particular class of errors.
Is there a way to set that up? So that "Notice" errors go into a Notice log file, Critical into a critical file?
Ideally, I'd like to be able to do something like:
$message->addNotice("$foo has been deleted.");
and then later...
$message->addCritical("$bar is missing.");
so that I'm using $message for everything, but the errors are going their separate ways.
Or do I need:
$messageNotice->addNotice("something");
$messageCritical->addCritical("something else");
and have different loggers for each type of error?
@Seldaek commented on GitHub (May 29, 2016):
You could use the FilterHandler to do that, basically creating 8 StreamHandlers with diff file names, and 8 FilterHandler wrapping them, each listening to one single level like e.g.
array(Logger::ERROR).Typically though I think it's better to filter the logs whenever you read them than when writing them, because otherwise reading a full request's logs becomes really hard if you have to combine 8 different files. Up to you though.