Giter Club home page Giter Club logo

Comments (2)

svetob avatar svetob commented on July 21, 2024

There is https://hexdocs.pm/logger/Logger.html#configure_backend/2, however this will restart the logger backend which can lead to lost messages, so I would not recommend doing it often.

Another option would be to list metadata fields not as subfields under metadata (metadata.field) but directly at root level (field). This is my preferred option, it seems to fit the actual use case for metadata better. And, it would allow you to set permanent fields per process using https://hexdocs.pm/logger/Logger.html#metadata/1. Would this work well for you?

We could also add some API to the LogstashJson module to accomplish this, but I would prefer to make this library work well with the standard Logger library.

from logstash-json.

nburkley avatar nburkley commented on July 21, 2024

We only need to do this once, on application startup so [Logger.configure_backend/2]
(https://hexdocs.pm/logger/Logger.html#configure_backend/2) should be sufficient.

I put together a proof-of-concept which included the following:

logstash_config = Application.get_env(:logger, :logstash)
logstash_fields = Map.put(logstash_config[:fields], "my_new_field", "my_new_value")
Logger.configure_backend({LogstashJson.TCP, :logstash}, [fields: logstash_fields])

When this is run on application startup, the new field/value "my_new_field" is included in all log messages.

Thanks for the help!

from logstash-json.

Related Issues (14)

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.