Description
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.