newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
198 stars 143 forks source link

Make agent logging ignore config in files #1753

Open meiao opened 7 months ago

meiao commented 7 months ago

Description

The Java agent uses a relocated (shadowed) packages for some libraries so it does not conflict with the application's dependencies. Log4J is one of these dependencies.

To prevent the customer's Log4J configuration from applying some steps are taken, such as temporarily removing system properties.

But the contents of the file log4j2.component.properties will be used to configure the agent's loggers. The contents of this file are read in PropertiesUtil.LOG4J_PROPERTIES. PropertyUtil does not seem to have a way to remove properties. So it will likely be needed to use reflection to get the private final Environment environment field and clear the collections inside of it. To make it more complicated, Environment is a private class.

It was not verified, but it is possible that the contents of log4j2.system.properties will also be used by the agent. But depending on how the environment is cleaned, it may also remove the contents of this file.

Acceptance Criteria

The contents of that file are not used to configure the agent's loggers, but will still be used to configure the application's loggers.

workato-integration[bot] commented 7 months ago

https://new-relic.atlassian.net/browse/NR-231377