Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to include/exclude Monolog logger channel on log forwarding #788

Open
tsantos84 opened this issue Nov 29, 2023 · 2 comments
Open

Allow to include/exclude Monolog logger channel on log forwarding #788

tsantos84 opened this issue Nov 29, 2023 · 2 comments
Labels
enhancement New feature or request PM PM to review against project priorities.

Comments

@tsantos84
Copy link

Summary

The PHP Agent allows to forward logs directly to NR servers but don't allow us to filter which log records we want to send, causing the sending of unwanted logs and impacting in the account billing.

Desired Behavior

Allow to developers to filter which logs records they want to forward to New Relic.

Possible Solution

Monolog \Monolog\Logger class has a mandatory constructor argument (eg. string $name) which tells the name of the logger instance and that argument will be passed as channel to LogRecord when $logger->log(...) is called. Frameworks like Symfony creates multiples instances of \Monolog\Logger each one having a diferente name/channel (eg. request, messenger, security, etc). The agent could use the channel property and allow us to filter which log record will be sent to NR servers.

Consider my application has 3 log channels:

$logger = new Logger('security');
$logger->info('Foo security message');

$logger = new Logger('doctrine');
$logger->info('Foo doctrine message');

$logger = new Logger('app');
$logger->info('Foo app message');

Now I want to send only app and doctrine channels to NR servers, I could configure the agent like this:

newrelic.application_logging.forwarding.monolog_channels_include=app,doctrine

Or

newrelic.application_logging.forwarding.monolog_channels_exclude=security

Additional context

I have undesired log records being sent to NR servers.

@tsantos84 tsantos84 added the enhancement New feature or request label Nov 29, 2023
@lavarou lavarou added the PM PM to review against project priorities. label May 6, 2024
@lavarou
Copy link
Member

lavarou commented May 6, 2024

@tsantos84 Thank you for submitting this feature request. It has been submitted on your behalf to the product team for evaluation.

@JulienChavee
Copy link

Hello,

It would be great to have the channel value in the metadata of the logs as well, to be able to query it.
Being able to do query on it would also allow to create drop filters based on this value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PM PM to review against project priorities.
Projects
None yet
Development

No branches or pull requests

3 participants