Comments (8)
The log4j configuration:
<Elasticsearch name="elasticsearchAsyncBatch">
<IndexName indexName="log4j2"/>
<AsyncBatchDelivery>
<IndexTemplate name="log4j2" path="classpath:indexTemplate.json"/>
<JestHttp serverUris="http://localhost:9200"/>
</AsyncBatchDelivery>
</Elasticsearch>
from log4j2-elasticsearch.
The pom element:
<dependency>
<groupId>org.appenders.log4j</groupId>
<artifactId>log4j2-elasticsearch-jest</artifactId>
<version>1.4.4</version>
</dependency>
from log4j2-elasticsearch.
If using classpath:indexTemplate.json
, indexTemplate.json must be at the root of one of your jars. But, it can also be loaded from an absolute path:
<IndexTemplate name="log4j2" path="/home/user/indexTemplate.json"/>
As this file is NOT a part of the released code (e.g. log4j2-elasticsearch-jest-1.4.4.jar), you have to prepare this file on your own. Have a look at the example. Make sure that indexPatterns
will match your index name (e.g. log4j2*
).
I'll add a full example here. You're welcome to contribute yours as well.
from log4j2-elasticsearch.
Ok, it seems that the problem is not related with the file location as now the file is found but the problem persists, I'm upgrading the log4j2 version from 2.7.1 to the one you are using 2.12.1 to see if this could be the cause of the issue.
from log4j2-elasticsearch.
You're right, it will work with >=2.8. But, due to future plans related to MutableInstant
introduced in Log4j2 2.11, only >=2.11 is supported.
Based on the attached stacktrace, there definitely was an issue with the file. If the file is found now and it still does not start, new stack trace will tell you the truth.
Unlike Spring Boot, pure Spring does not provide Jackson, Log4j2 and Apache HTTP dependencies. This plugin - by design - have them all in provided
scope in order to make you more aware of what you're adding to the classpath, so there may be more work to do to before you get it to run. It's worth it though :)
Let me know how did it go. I'll gladly help you if you have any issues.
from log4j2-elasticsearch.
I have upgraded my project to use log4j 2.12.1.
The problem persists in my project, in your jest example you have an <JacksonJsonLayout>
element on the log4j configuration xml, removing the element from the example causes the same exception.
But this element is not mandatory, is it ?
Thanks!
from log4j2-elasticsearch.
Layout must be configured. You can use JacksonJsonLayout
, JsonLayout
or any other layout that will serialize the log events to JSON. I just realized that the documentation is wrong. Thank you!
You can you use JacksonJsonLayout
with JestHttp
like this:
<JacksonJsonLayout/>
JestBufferedHttp
and HCHttp
require buffers, so you'll need PooledItemSourceFactory
config:
<JacksonJsonLayout>
<PooledItemSourceFactory itemSizeInBytes="1024" initialPoolSize="1000" />
</JacksonJsonLayout>
<HCHttp>
<PooledItemSourceFactory itemSizeInBytes="1024000" initialPoolSize="1" />
</HCHttp>
JsonLayout
can be used only with JestHttp
as it can't provide buffers:
<JsonLayout compact="true" />
(compact="true" is crucial as it uses MinimalPrettyPrinter
under the hood; without this flag ES won't ingest pretty printed JSON)
Are you still getting exceptions after this?
from log4j2-elasticsearch.
After adding
<JacksonJsonLayout/>
The ConfigurationException is gone.
Thanks a lot
from log4j2-elasticsearch.
Related Issues (20)
- 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
- GenericItemSourcePool.unlatchAndResetResizing might cause an error HOT 1
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.