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

Implement the logger-log4j module using log4j apis directly #756

Merged
merged 3 commits into from
Jul 25, 2022

Conversation

carterkozak
Copy link
Contributor

This is meant to avoid slf4j indirection, and use a code-path
with better test coverage within log4j itself. For example,
this implementation will avoid the unintended allocations
incurred by LOG4J2-3560.

This module uses a bridge with dynamic priority based on the
presence of log4j-core. In the case that log4j-core is present,
it's preferred over the default.

In practice, we will ship this as a runtime dependency of our internal
logging framework, invisible to consumers.

After this PR

==COMMIT_MSG==
Implement the logger-log4j module using log4j apis directly
==COMMIT_MSG==

Possible downsides?

More to maintain

This is meant to avoid slf4j indirection, and use a code-path
with better test coverage within log4j itself. For example,
this implementation will avoid the unintended allocations
incurred by LOG4J2-3560.

This module uses a bridge with dynamic priority based on the
presence of log4j-core. In the case that log4j-core is present,
it's preferred over the default.
@changelog-app
Copy link

changelog-app bot commented Jul 25, 2022

Generate changelog in changelog/@unreleased

Type
See change types. Select one:

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Implement the logger-log4j module using log4j apis directly

Check the box to generate changelog(s)

  • Generate changelog entry

@@ -1 +1,4 @@
org.gradle.parallel=true
# Avoid formatting copyrights, which are formatted in a
# slightly non-standard way due to javapoet codegen.
com.palantir.baseline-format.copyright=false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will opt us out of unintentionally formatting generated classes that we check in

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block was added by robots, shouldn't happen anymore

Copy link
Contributor

@schlosna schlosna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, thanks for putting this together @carterkozak ! Left a few comments/questions

@@ -0,0 +1,61 @@
/*
* (c) Copyright 2021 Palantir Technologies Inc. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
* (c) Copyright 2021 Palantir Technologies Inc. All rights reserved.
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.

versions.props Outdated
@@ -16,4 +16,5 @@ com.google.errorprone:error_prone_refaster = 2.3.3

# Don't automatically force everything to upgrade slf4j
org.slf4j:slf4j-api = 1.7.31
org.apache.logging.log4j:* = 2.17.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we intentionally pinning on 2.17.2 for older support? Should we add a comment about when we'd want to unpin? 2.18.0 has been out for about a month now and making its way through automated upgrades.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I hadn't used a compileOnly dependency, the goal here was to avoid pushing framework upgrades faster than our standard machinery might intend (which don't pin back releases, in fact the new version was bundled into products within hours of the release)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated using the latest release, un-pinned

Comment on lines +9 to +13
Logger facades delegate to logger implementations. Unfortunately we
cannot opt out of specific custom rules, otherwise we would only
opt out of 'BanLoggingImplementations'.
-->
<suppress files="[/\\]logger-.*Bridge\.java" checks="IllegalImport" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this suppression given this project is explicitly is dealing with loggers, but one workaround would be to use/generate fully qualified type names where used for the things we consider illegal so they aren't imported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an option, but it would impact readability of the generated code, so I opted against it.

@bulldozer-bot bulldozer-bot bot merged commit ae76dad into develop Jul 25, 2022
@bulldozer-bot bulldozer-bot bot deleted the ckozak/log4j branch July 25, 2022 16:58
@svc-autorelease
Copy link
Collaborator

Released 1.28.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants