Giter VIP home page Giter VIP logo

Comments (8)

jmdopereiro avatar jmdopereiro commented on May 28, 2024

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.

jmdopereiro avatar jmdopereiro commented on May 28, 2024

The pom element:

    <dependency>
        <groupId>org.appenders.log4j</groupId>
        <artifactId>log4j2-elasticsearch-jest</artifactId>
        <version>1.4.4</version>
    </dependency>

from log4j2-elasticsearch.

rfoltyns avatar rfoltyns commented on May 28, 2024

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.

jmdopereiro avatar jmdopereiro commented on May 28, 2024

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.

rfoltyns avatar rfoltyns commented on May 28, 2024

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.

jmdopereiro avatar jmdopereiro commented on May 28, 2024

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.

rfoltyns avatar rfoltyns commented on May 28, 2024

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.

jmdopereiro avatar jmdopereiro commented on May 28, 2024

After adding

<JacksonJsonLayout/>

The ConfigurationException is gone.

Thanks a lot

from log4j2-elasticsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.