ecs-logging-java | Centralized logging for Java applications
kandi X-RAY | ecs-logging-java Summary
kandi X-RAY | ecs-logging-java Summary
Centralized logging for Java applications with the Elastic stack made easy
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Formats a log record
- Builds the file name
- Formats the log record
- Builds the file name
- Starts the downloader
- Downloads a file from a URL
- Format a logging event
- Extracts the line number from a location information
- Gets a configuration property
- Start the event converter
ecs-logging-java Key Features
ecs-logging-java Examples and Code Snippets
Community Discussions
Trending Discussions on ecs-logging-java
QUESTION
I have a Springboot micro-service. For logging I'm using Elastic common scheme, implemented using ecs-logging-java.
I want to set the trace.ID and a transaction.ID but I'm not sure how?
Bonus question, I'm I right in thinking trace.ID should be the ID to following the request through multiple system. transaction.ID is just for within the service?
...ANSWER
Answered 2020-May-22 at 22:23I thought I had documented this but the closest I could come is in Log4j-Audit's RequestContext.. I guess I need to add a new entry to my blog. The short answer to this is that you use Log4j 2's ThreadContextMap. First, when a user logs in create a session map that contains the data you want to capture in each request, such as the user's ip address and loginId. Then create servlet Filter or Spring Interceptor to add that data as well as a unique request id to Log4j 2's Thread Context Map.
All Leg Events will include the data in the ThreadContext. The ECSLayout automatically includes all the fields in the ThreadContextMap.
Lastly, you need to propagate the RequestContext to downstream services. You do that by creating a Spring Interceptor that gets wired into the RestTemplate which converts the RequestContext fields into HTTP headers. The downstream service then has a Filter or Spring Interceptor that converts the headers back into RequestContext attributes. Log4j Audit (referenced above) has examples and implementations of all these components.
I should add that the method described above does not implement tracing as described by the WSC Trace Context spec so it is also not compatible with Elasticsearch's distributed tracing support. It is worth noting however, that if one were to include Elasticsearch's distributed tracing support along with New Relic's distributed tracing support they would step on each other.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ecs-logging-java
You can use ecs-logging-java like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ecs-logging-java component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page