Problem/Motivation

In addition to the Logger, there is also a great Monolog module that is able to store structured metadata too.

Would be great to implement a Monolog Handler to provide the ability to store logs from Monolog to the database too, in addition to the Logger data source.

Also, provide a fallback to work well with the Drupal Core logger, without any additional modules.

Issue fork logger_db-3555898

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

murz created an issue. See original summary.

murz’s picture

Status: Active » Needs review

Made a quick implementation - it seems to work well, but needs review and deeper testing, so would be great to receive feedback from Monolog users, moving to "Needs review".

lussoluca’s picture

Status: Needs review » Reviewed & tested by the community

LGTM, thanks!

mxr576’s picture

Generally speaking, it looks good to me.

I have some ideas on how to postpone the initialization of the monolog handler when monolog is not enabled on the project, like with a ServiceProvider+CompilerPass combination or only access dependencies in the handler when they are actually needed via a service closure.

https://www.drupal.org/node/3451855

murz’s picture

Status: Reviewed & tested by the community » Needs review

I have some ideas on how to postpone the initialization of the monolog handler when monolog is not enabled on the project

But in what cases the service monolog.handler.logger_db can be initialized if Monolog is not is not enabled? It will be just a definition in the list of services, with no initialization, as I understand.

mxr576’s picture

You can be right about that, but the definition exists inside the service container and could be accessed via its ID.

murz’s picture

Yes, just +1 definition for 1000 already existing ones will not make the things worse :) Alternatively, we should implement the dynamic service provider or hook, that will just overcomplicate the things with no benefits.

So, let's keep it as is. Who use Monolog on real projects, could you please check if this works well and provides suitable format of the log entry in the database? Cuz I use only Logger on my projects ;) and has not a lot of experience with Monolog.

murz’s picture

Alternatively, I can introduce a new submodule logger_db_monolog or a separate project, but I think it's too much for such a simple task.

mxr576’s picture

Issue tags: +Needs tests

So, let's keep it as is. Who use Monolog on real projects, could you please check if this works well and provides suitable format of the log entry in the database? Cuz I use only Logger on my projects ;) and has not a lot of experience with Monolog.

Added "Needs tests" tag ;P

murz’s picture

Title: Implement a handler for Monolog logger » Add support for Monolog and Drupal Core logger without the Logger module
Issue summary: View changes
Issue tags: -Needs tests

Finally, with the Logger module improvements in the 1.0.0-alpha6, able to implement the planned functionality!

Now the Logger DB module has no mandatory dependencies and can work well with the default Drupal Core logger!

And if the Monolog module is installed, it adds the handler to work well with the Monolog module too.

And, of course, detects the Logger module and works well with it too.

Added tests to cover all the cases, but still need manual testing, reviewing the changes and feedback.

murz’s picture

Issue tags: +AI Initiative, +Chicago2026

  • murz committed ad2bccb4 on 1.0.x
    feat: #3555898 Add support for Monolog and Drupal Core logger without...
murz’s picture

Status: Needs review » Fixed

Thank yall, the feature is finally stabilized, finalized and merged! Now the Logger DB works well on its own, without any dependencies, and automatically extends the functionality if the Logger or Monolog is installed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

murz’s picture

Status: Fixed » Closed (fixed)