Open Jakhotiya opened 5 years ago
Thanks for the idea.
di.xml
. env.php
seems like a good place
- Agree that config for the logger should be in a config file rather than in
di.xml
.env.php
seems like a good place
3. I would not inject request and state in the logger directly as it will make them dependent on global state (e.g., request will not work in CLI mode).
This should be made possible cause its the most important information to understand the context of a issue under investigation.
Even if its coupling it can be optional or usable:
This should be made possible cause its the most important information to understand the context of a issue under investigation.
I also don't like an idea to include the request details to DB logging. But as a possible approach to achieve the context - correlation ID might be used to combine all logging details (not only DB) in the same context.
Abstract
At the moment, when you turn on query logging, you can only filter queries using the time parameter. We need to be able to log queries for
Other wise we end up with a log size of several GB's Often on live environments, we encounter intermittent issues. We may not know how to replicate them. OR developer working with extension that deals with third party API, like M2epro. And it's painful to figure out how a certain thing is happening.
For the past year, I've been using Magento 2 query log along with stack traces to figure out "How" something happens or how to replicate an issue. For example If I know that a bug is causing changes in a table A, I need to know all queries and the stack traces causing change in table A. So I keep the query log on for a day, in order to catch the intermittent issue. I then analyse the log. But this is a painful experience because I might be looking at 3-4 GB of log. Timing filters are not very useful if you don't know "what the query is " OR "how much time does it take on average" Having advanced filters would make the debugging experience better.
We can implement three kinds of filters
Random thoughts on implementation.
For the time being I go into the core file vendor/magento/framework/DB/Logger/File.php I make changes to this file directly on the server when I want advanced filtering. I add
to the constructor.
Next I make changes to
log
function andlogStats
functionThis is very raw implementation. I extracted this whole code into class "\Magento\Framework\DB\Logger\Advanced".
I would want all of those parameters to be configurable using "app/etc/env.php"
May be we could modify the parameters to look like
If this sounds useful to other developers too , can anybody guide me on how I can wire it existing Logging mechanism.