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

Add local decorating for customers using Log4j 2 with JsonTemplateLayout #1866

Merged
merged 7 commits into from
Apr 24, 2024

Conversation

obenkenobi
Copy link
Contributor

@obenkenobi obenkenobi commented Apr 18, 2024

Overview

Adds local decorating (i.e. NR-LINKING metadata) to log4j 2 logs using JsonTemplateLayout such as shown configured in the XML snippet below:

	<Appenders>
		<Console name="Console" target="SYSTEM_OUT">
                         <JsonTemplateLayout eventTemplateUri="classpath:JsonLayout.json"/>
		</Console>
	</Appenders>

Example log without local decorating:

{
  "@timestamp": "2024-04-18T21:08:01.250Z",
  "log.level": "INFO",
  "process.thread.name": "http-nio-8081-exec-1",
  "log.logger": "org.springframework.samples.petclinic.system.WelcomeController",
  "message": "info bar"
}

Example log with local decorating:

{
  "@timestamp": "2024-04-18T21:08:01.250Z",
  "log.level": "INFO",
  "process.thread.name": "http-nio-8081-exec-1",
  "log.logger": "org.springframework.samples.petclinic.system.WelcomeController",
  "message": "info bar NR-LINKING|MzQ3Nzg3NHxBUE18QVBQTElDQVRJT058NTM4Mzc3ODY0|192.168.0.31|e0a726b1de7a78af9e74bfb042845180|3f4885dca4f83070|Petclinic+Log4j+Jsontemplatelayout+decorating|"
}

Related Github Issue

#1730

Copy link
Contributor

@jasonjkeller jasonjkeller left a comment

Choose a reason for hiding this comment

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

Couple of minor tweaks to be made but otherwise looks good.

@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 27 lines in your changes are missing coverage. Please review.

Project coverage is 70.69%. Comparing base (0e3a23f) to head (0117d92).
Report is 110 commits behind head on main.

Files Patch % Lines
.../com/newrelic/agent/bridge/logging/Log4jUtils.java 0.00% 27 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1866      +/-   ##
============================================
- Coverage     70.88%   70.69%   -0.19%     
+ Complexity     9974     9872     -102     
============================================
  Files           829      828       -1     
  Lines         39985    39832     -153     
  Branches       6058     6064       +6     
============================================
- Hits          28344    28161     -183     
- Misses         8915     8947      +32     
+ Partials       2726     2724       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@obenkenobi obenkenobi merged commit 0ef184a into main Apr 24, 2024
110 checks passed
@obenkenobi obenkenobi deleted the log4j2-jsontemplatelayout branch May 2, 2024 21:27
@obenkenobi obenkenobi restored the log4j2-jsontemplatelayout branch May 2, 2024 21:27
@obenkenobi obenkenobi deleted the log4j2-jsontemplatelayout branch May 2, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants