Comments (14)
Use log4j2-elasticsearch-jest
module. log4j2-elasticsearch-core
is required only if you use programmatic config or extend Core modules.
from log4j2-elasticsearch.
@thilankadileepa You can use ThreadContext
as decribed here.
Also, JacksonJsonLayout:VirtualProperty[]
will be added in 1.4 (to be released this year) - it will allow to define properties similar to JsonLayout:KeyValuePair[]
. It's already in master and it's documented here.
from log4j2-elasticsearch.
Thanks a lot.
To use the JacksonJsonLayout:VirtualProperty, what is the library that I should use ?
Is it
org.appenders.log4j
log4j2-elasticsearch-jest
1.3.5
or
org.appenders.log4j log4j2-elasticsearch-core 1.3.5Please note that I have ES version 7.
Best Regards,
Thilanka
from log4j2-elasticsearch.
@thilankadileepa It's not released yet (not available in 1.3.5). It will be available as part of 1.4 Core later this year.
from log4j2-elasticsearch.
Can I build it by myself and use ?
I am working on a system which plan to go live this year and this library is extremely useful for me. If I can add one additional field (sessionId) my requirement is fully covered.
I have tried it for 2 days but couldn't locate it yet, if you can share an example with me will be a great.
from log4j2-elasticsearch.
Yes, you can build your own fork if you can't wait for the release.
You can find the example of JacksonJsonLayout:VirtualProperty[]
config here.
If you don't want to maintain your own fork internally, JsonLayout:KeyValuePair[]
should give you the same functionality - it will have a bigger memory footprint though as buffer pools can't be configured in this case.
from log4j2-elasticsearch.
Thanks
I have build it and add the following dependancy
org.appenders.log4j
log4j2-elasticsearch-core
1.4.0-SNAPSHOT
My log4j2.xml looks similar to the example.
And I have added the provided dependencies as well.
I am getting the following error on startup.
2019-10-16 06:54:09,215 main ERROR Error processing element JestBufferedHttp ([AsyncBatchDelivery: null]): CLASS_NOT_FOUND 2019-10-16 06:54:10,096 main ERROR No Elasticsearch client factory [JestHttp|ElasticsearchBulkProcessor] provided for AsyncBatchDelivery: clientObjectFactory 2019-10-16 06:54:10,097 main ERROR Could not create plugin of type class org.appenders.log4j2.elasticsearch.AsyncBatchDelivery for element AsyncBatchDelivery org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element AsyncBatchDelivery are invalid: field 'clientObjectFactory' has invalid value 'null' at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:209) at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
from log4j2-elasticsearch.
Thank You :)
I have changed it to log4j2-elasticsearch-jest as advised.
Seems its goes in the correct path and I am getting the following exception.
**Exception in thread "BatchNotifier" java.lang.NoSuchMethodError: org.appenders.log4j2.elasticsearch.jest.BufferedBulk.getURI()Ljava/lang/String;** at org.appenders.log4j2.elasticsearch.jest.BufferedJestHttpClient.prepareRequest(BufferedJestHttpClient.java:63) at org.appenders.log4j2.elasticsearch.jest.BufferedJestHttpClient.executeAsync(BufferedJestHttpClient.java:47) at org.appenders.log4j2.elasticsearch.jest.JestHttpObjectFactory$1.apply(JestHttpObjectFactory.java:194) at org.appenders.log4j2.elasticsearch.jest.JestHttpObjectFactory$1.apply(JestHttpObjectFactory.java:177)
from log4j2-elasticsearch.
It caused by latest Jest jars. io.seachbox:jest:6.3.0
replaced io.searchbox.action.AbstractAction.getURI()
with io.searchbox.action.AbstractAction.getURI(ElasticsearchVerision)
.
It will work once you remove dependency on io.seachbox:jest:6.3.0
or provide an explicit dependency on io.seachbox:jest:2.4.0
(as specified by this plugin's POM).
Other option is to switch to log4j2-elasticsearch-hc
(and compatible XML config) which doesn't have a dependency on Jest jars.
from log4j2-elasticsearch.
Finally I managed to do that :)
Thanks a lot for the help with quick responses.
from log4j2-elasticsearch.
Great news! Glad to help! :)
Feel free to close this issue if you feel that everything was addressed.
from log4j2-elasticsearch.
Final Question
How can I add this dynamically per each request ? For example a session id for each transaction ?
I was managed to add a constant and an env variable as a VirtualProperty
from log4j2-elasticsearch.
Try using ThreadContext
and
<VirtualProperty name="propName" value="$${ctx:sessionId}" dynamic="true" />
.
Options available in the value
field are well documented in Log4j2 documentation.
from log4j2-elasticsearch.
Thanks :)
from log4j2-elasticsearch.
Related Issues (20)
- Supporting ecs-logging-java HOT 8
- Package naming conventions HOT 11
- How to pass the value from ThreadContext to ValueProperty? HOT 3
- Can not log to elastic using log4j2 <PatternLayout> HOT 11
- Support elasticsearch data_streams HOT 6
- Failed to Load StackTraceElementMixIn HOT 22
- InvalidTypeNameException on invalid mappingType in ES 5 HOT 8
- Adding custom properties, that change during processing HOT 4
- Log4j2 Zero-Day vulnerability (CVE-2021-44228) HOT 2
- Support OpenSearch 2.x and Elasticsearch 8.x HOT 9
- Unable to determine if index already exists HOT 1
- Support for ECSLayout for elasticsearch-ahc and / or elaticsearch-jest in combination with data streams HOT 10
- Is it possible to deseriailze JSON within the message into properties? HOT 2
- Run elastic search appender in specific environment HOT 2
- Logging-Cleaner ERROR Could not create plugin HOT 3
- How do I add mdc attributes? HOT 1
- Could not initialize ChronicleMapRetryFailoverPolicy HOT 2
- ServiceDiscovery ERROR HCServiceDiscovery: Unable to refresh addresses: Cannot invoke "org.appenders.log4j2.elasticsearch.hc.discovery.NodeInfo$PublishAddress.getPublishAddress()" HOT 1
- Using log4j2-elasticsearch-hc -> Does AsyncLogger still not support adding dynamic keyValue pairs in Jackson JSONLayout HOT 5
- IS JacksonModule is implemented in latest version? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from log4j2-elasticsearch.