[GH-ISSUE #689] Read log files with monolog? #254

Closed
opened 2026-03-04 02:13:30 +03:00 by kerem · 2 comments
Owner

Originally created by @ghost on GitHub (Nov 20, 2015).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/689

Is it possible to read log files which are written with monolog?
If not: Is there any PHP library which is working on this?

I like to add a "view logs" page to our administration interface.

Originally created by @ghost on GitHub (Nov 20, 2015). Original GitHub issue: https://github.com/Seldaek/monolog/issues/689 Is it possible to read log files which are written with monolog? If not: Is there any PHP library which is working on this? I like to add a "view logs" page to our administration interface.
kerem closed this issue 2026-03-04 02:13:31 +03:00
Author
Owner

@quantumpacket commented on GitHub (Nov 21, 2015):

You can save the log files as JSON using the JsonFormatter. You then basically do the following:

$logDetails = json_decode(file_get_contents(...));

Keep in mind the size of the log files as this basic example would load it all into memory. You'd want to cache what you want, or rotate logs when they reach an acceptable max size.

There are also options to save log records to a database. This would be easier for retrieval, but depending on how many records are being logged for each request based on your application it may impact performance.

You should just check out the documentation to find what suits your needs.

<!-- gh-comment-id:158566070 --> @quantumpacket commented on GitHub (Nov 21, 2015): You can save the log files as JSON using the `JsonFormatter`. You then basically do the following: ``` php $logDetails = json_decode(file_get_contents(...)); ``` Keep in mind the size of the log files as this basic example would load it all into memory. You'd want to cache what you want, or rotate logs when they reach an acceptable max size. There are also options to save log records to a database. This would be easier for retrieval, but depending on how many records are being logged for each request based on your application it _may_ impact performance. You should just check out the [documentation](https://github.com/Seldaek/monolog/blob/master/doc/02-handlers-formatters-processors.md) to find what suits your needs.
Author
Owner

@Seldaek commented on GitHub (Nov 21, 2015):

There is no way and IMO it's out of scope for monolog, there are many existing solutions (although not in PHP that I know of), from Logstash to Heka to a zillion third party services that monolog supports logging to.

<!-- gh-comment-id:158575499 --> @Seldaek commented on GitHub (Nov 21, 2015): There is no way and IMO it's out of scope for monolog, there are many existing solutions (although not in PHP that I know of), from Logstash to Heka to a zillion third party services that monolog supports logging to.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#254
No description provided.