Giter VIP home page Giter VIP logo

Comments (4)

felixbarny avatar felixbarny commented on July 26, 2024 2

As a workaround, you could set these properties as key/value pairs that already support lookups:

<EcsLayout serviceName="myservice">
  <KeyValuePair key="service.version" value="$${spring:project.version}"/>
  <KeyValuePair key="service.node.name" value="${env:HOSTNAME}"/>
</EcsLayout>

from ecs-logging-java.

eyalkoren avatar eyalkoren commented on July 26, 2024

This sounds like an interesting feature, but not sure how soon we can prioritize it.
Would you like to give it a shot and try to implement yourself? If so, please create a PR. We still can't guarantee we would review that immediately, but for sure it would be prioritized higher as a PR.

Without looking into how it's implemented, I would first look for an access to the internal log4j2 code that parses, substitutes and does the lookup. I doubt if we would like to add the entire logic (and documentation) to do it within the ECS-logging library. Another hint if you try it out is that it will have to be compatible with all supported versions (2.6+).

from ecs-logging-java.

fbaligand avatar fbaligand commented on July 26, 2024

Great workaround @felixbarny!
Thanks for the share!

And thanks to have added this example into documentation!
https://www.elastic.co/guide/en/ecs-logging/java/master/setup.html

from ecs-logging-java.

kelunik avatar kelunik commented on July 26, 2024

Setting log4j2.formatMsgNoLookups is a (now discredited) mitigation for CVE-2021-45046. Lookups in the (user-provided) message have now been completely removed in log4j2 2.16, see also https://issues.apache.org/jira/browse/LOG4J2-3211.

However, setting log4j2.formatMsgNoLookups also disables lookups for <KeyValuePair /> defined in the configuration, because they're disabled here:

} else if (valueNeedsLookup(additionalField.getValue()) && !FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS) {

<KeyValuePair key="service.environment" value="${sys:environment}" />

This prevents lookups (i.e. ${...:...} – not %X etc.) from working even if defined in the configuration file.

What's the recommendation here? Simply not setting log4j2.formatMsgNoLookups anymore, because lookups have now been removed anyway? If so, why is this property still respected here?

from ecs-logging-java.

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.