Comments (2)
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.
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)
- Reconnnect on connection issues HOT 2
- Under heavy logging, an application can become unresponsive HOT 2
- Remove timex dependency
- Add a formatter for TCP logging HOT 1
- application is crashed on some data HOT 3
- Use Travis CI
- Publish new hex package HOT 1
- Unchecked dependencies for environment tes HOT 4
- Optional JSON library selection HOT 1
- Use message formatter from :console
- UDP appender HOT 1
- Add :error_log parameter
- cannot import in logstash HOT 3
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 logstash-json.