mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 12:47:39 +02:00
Add docs about reset()
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
- [Adding extra data in the records](#adding-extra-data-in-the-records)
|
||||
- [Leveraging channels](#leveraging-channels)
|
||||
- [Customizing the log format](#customizing-the-log-format)
|
||||
- [Long running processes and avoiding memory leaks](#long-running-processes-and-avoiding-memory-leaks)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -226,4 +227,22 @@ $securityLogger->pushHandler($stream);
|
||||
You may also reuse the same formatter between multiple handlers and share those
|
||||
handlers between multiple loggers.
|
||||
|
||||
## Long running processes and avoiding memory leaks
|
||||
|
||||
When logging lots of data or especially when running background workers which
|
||||
are long-lived processes and do lots of logging over long periods of time, the
|
||||
memory usage of buffered handlers like FingersCrossedHandler or BufferHandler
|
||||
can rise quickly.
|
||||
|
||||
Monolog provides the `ResettableInterface` for this use case, allowing you to
|
||||
end a log cycle and get things back to their initial state.
|
||||
|
||||
Calling `$logger->reset();` means flushing/cleaning all buffers, resetting internal
|
||||
state, and getting it back to a state in which it can receive log records again.
|
||||
|
||||
This is the conceptual equivalent of ending a web request, and can be done
|
||||
between every background job you process, or whenever appropriate. It reduces memory
|
||||
usage and also helps keep logs focused on the task at hand, avoiding log leaks
|
||||
between different jobs.
|
||||
|
||||
[Handlers, Formatters and Processors](02-handlers-formatters-processors.md) →
|
||||
|
Reference in New Issue
Block a user