Skip to content

Return ContentType of "application/json" instead of "text/plain" #90

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

Merged
merged 2 commits into from
Aug 26, 2020

Conversation

yorondevops
Copy link
Contributor

Override the ECSLayout parent class's (org.apache.logging.log4j.core.layout.AbstractStringLayout line 222) "getContentType()" function which always returns text/plain, so that it returns the ECS-appropriate application/json instead.

This change adds support for use of the ECS Layout in conjunction with the log4j2 HTTP #Appender

Usage of the layout's "getContentType()" function can be seen on line 89 of the HttpURLConnectionManager class, in the "send()" function ,which decides the Content-Type header the logs will be sent with.

This PR is to help close #89

…tractStringLayout's getContentType() that returns a more ECS appropriate 'application/json'
@cla-checker-service
Copy link

cla-checker-service bot commented Aug 25, 2020

💚 CLA has been signed

@apmmachine
Copy link
Contributor

apmmachine commented Aug 25, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Started by user Felix Barnsteiner, Replayed #3]

  • Start Time: 2020-08-26T07:00:05.255+0000

  • Duration: 7 min 49 sec

Test stats 🧪

Test Results
Failed 0
Passed 104
Skipped 4
Total 108

@yorondevops
Copy link
Contributor Author

Hi, I signed the "Contributor Agreement", any idea how I can get the checks to run again?

@felixbarny
Copy link
Member

I have re-run the check. All good now!

@yorondevops
Copy link
Contributor Author

Looks like the Jenkins job failed because I placed the function in the nested .Builder class instead of the ecslayout class,
fixed it

@yorondevops
Copy link
Contributor Author

Looks like the maven build is failing now because of connectivity issues?
09:47:59 [ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.19:update-file-header (first) on project ecs-logging-java-parent: Execution first of goal org.codehaus.mojo:license-maven-plugin:1.19:update-file-header failed: Plugin org.codehaus.mojo:license-maven-plugin:1.19 or one of its dependencies could not be resolved: Failed to collect dependencies at org.codehaus.mojo:license-maven-plugin:jar:1.19 -> org.apache.maven:maven-plugin-api:jar:3.0 -> org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2: Failed to read artifact descriptor for org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2: Could not transfer artifact org.sonatype.sisu.inject:guice-plexus:pom:1.4.2 from/to central (https://repo.maven.apache.org/maven2): Connection reset -> [Help 1]

@felixbarny
Copy link
Member

I ran the tests again and now it succeeded. Seemed to be a transient networking issue.

@felixbarny felixbarny merged commit 9a9b799 into elastic:master Aug 26, 2020
@yorondevops yorondevops deleted the content_type_option branch August 26, 2020 10:01
@yorondevops
Copy link
Contributor Author

@felixbarny, thanks for all the help! When can i expect to see a new release with this fix?

@felixbarny
Copy link
Member

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

Successfully merging this pull request may close these issues.

Set Content-Type Header when using EcsLayout with HTTPAppender in Log4J2
3 participants