Consider implementing Laravel Logging Service #7966
Replies: 21 comments 1 reply
-
@asmecher Could you please take a look on this PRs? If it's okay, I will create the ones for OMP/OPS. |
Beta Was this translation helpful? Give feedback.
-
Just tagging a related issue with some supporting discussion, that depends on this: #7568 |
Beta Was this translation helpful? Give feedback.
-
@henriqueramos can you please provide some more information about the different logging channels configured in your PR, how devs would use these logs, what they look like when we read them, etc? It's impossible to evaluate the benefits of this without some concrete examples. |
Beta Was this translation helpful? Give feedback.
-
Of course @NateWr! On the link I added at the description, there's a description about the channels, how they work and so on. But for historical purposes, I will add it here. About LoggingLogging is based on "channels". Each channel represents a specific way of writing log information. For example, the Laravel under the hood uses Monolog. So we could create multiple handlers to customize the message payload, for example. Log LevelsTake note of the The log levels defined in the RFC 5424 specification: emergency, alert, critical, error, warning, notice, info, and debug, are available to use. ChannelsEach log channel is powered by a "driver". The driver determines how and where the log message is actually recorded. On our implementation (at this moment) there's the following channels available:
How to useInject the
Your logs will reside on
And there's more, you could customizing |
Beta Was this translation helpful? Give feedback.
-
Thanks @henriqueramos! In addition to the Laravel docs, the key questions I want to be answered for our project are:
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@henriqueramos, this is not a bad idea, but I'd like to put it on ice for the moment; it's not a high priority and we have plenty of other things that come first. |
Beta Was this translation helpful? Give feedback.
-
This is my concern. It seems like we're adding a new pattern, but not really gaining much. What I'm hoping to see is a proposal for a coding convention that identifies what type of events should lead to what type of logs. If it's all going to one log, it doesn't seem to add much beyond the apache |
Beta Was this translation helpful? Give feedback.
-
I think there's a misconception about Logging here (and what this implementation does). The location where logs will reside doesn't matter, after all. You could send to one file inside your application (like Let me try to explain how granularity help the Devs/Sysadmins with a simple metaphor. Imagine you have an android friend and you ask him about how his day.
This is what granularity does for you. Instead of sending lots of data (and probably non-formatted ones) to your log ingestion tool (file, Saas or on-promise instances), you have the possibility to choose which kind of logging level you want to persist and how transform this data before send it. You could even add contextual information using the Laravel's Monolog implementation It's far easier to parse (and read) this kind of data on your ingestion tool (or search using vi/vim/nano/gedit/(any CLI tool):
than this normal apache's
And on the context of logs being one of the three pillars of Observability, he's alone isn't a silver bullet, of course. |
Beta Was this translation helpful? Give feedback.
-
@henriqueramos, this is bikeshedding; as I said it's not necessarily a bad idea but it's not a current requirement in the software and I asked you not to work on it for the moment. There are other higher priorities. |
Beta Was this translation helpful? Give feedback.
-
Understood @asmecher. Besides the Scheduling Task on #4622, we have the Laravel Routing system on #7698 to be done. But I'd like to highlight there's this log stuff comes alive during the rewrite of Scheduling Task on #4622 as a side effect. I just splitted the tasks to do a better tracking of it. |
Beta Was this translation helpful? Give feedback.
-
Laravel uses Monolog - https://github.com/Seldaek/monolog. Not sure what Laravel brings to the table compare to bare bone Monolog, though I am sure Laravel dev. in here can point out? The most important part is to make sure the lib is PSR-3 - https://www.php-fig.org/psr/psr-3/meta/ compliment. These days most modern libraries are. +1 from me pulling out any custom logging and leverage libs like Monolog that is widely used - https://packagist.org/packages/monolog/monolog |
Beta Was this translation helpful? Give feedback.
-
@steinmb, is there a motivating use case for adopting Monolog (or Laravel logging) over PHP |
Beta Was this translation helpful? Give feedback.
-
@asmecher these logging tools normally allows us to configure the logs in a generic way, e.g.:
It also provides such constructions: if ($logger->isDebugEnabled()) {
$message = possiblySlowOperationJustUsedByTheLog();
$logger->debug($message);
} |
Beta Was this translation helpful? Give feedback.
-
@jonasraoni right now we don't have any code in the system that logs events like this. We're still looking for a motivating use case that demonstrates where exactly in the code we would implement
For example: when Event A happens we should be logging to Channel B because User C wants to observe that event. |
Beta Was this translation helpful? Give feedback.
-
It should make sense to log events outside what php automagically sends of notices, warnings and errors to server default configured log. Example, user created, access blocked, payment events, and so on. If the core developers think there is no use case for logging events in the running application, perhaps this issue should be closed? (ps: I am new to this code base). |
Beta Was this translation helpful? Give feedback.
-
About the different levels of logging, here's a good reasoning: About deciding what's interesting to listen to, and what to do with the events I think that's a responsibility of the sysadmin/developer. For example a sysadmin might decide to collect more detailed logs to discover why an operation is failing, so he might temporarily increase the granularity before attempting to simulate an issue (a high granular log could contain HTTP requests/responses, SQL queries, etc). By default, we just can provide some reasonably good defaults (like the |
Beta Was this translation helpful? Give feedback.
-
Ah, about priorities: I don't see this type of logging as a requirement for our use case, we're not dealing with high sensitive information, so it's just an improvement that might be adopted slowly :) |
Beta Was this translation helpful? Give feedback.
-
I think we're going around in circles here because we don't quite understand each other. Let's talk about this on the dev call today. |
Beta Was this translation helpful? Give feedback.
-
Just leaving this minor issue, which depends on the Laravel's Log: #7568 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Currently, to send data to the syslog, we only have the built-in method
error_log
.We should consider implement the Laravel Logging Service.
This will help us to create log channels and use different levels for logs.
Beta Was this translation helpful? Give feedback.
All reactions