Comments (4)
Ahh ha. You've been exploring the innards then :)
Yes, for a while there was no public API for setting them and they were an internal implementation detail (a way to pass structured data in a mostly safe way from frontend to backend). Since they got used more and more, I decided to expose a "with()" method for setting them, along with using strongly typed keys. However since this was a bit experimental I put it in the Google extension API, not the core API (at least until we were sure it was working as intended).
It can be easily promoted into the core API if it would help (and if you have any feedback on it and how it works, please let me know). See:
https://github.com/google/flogger/blob/master/google/src/main/java/com/google/common/flogger/GoogleLoggingApi.java
You could, as a test, use the GoogleLogger and the "with()" method in its API to set tags.
from flogger.
I'm looking again at backends and adding a log4j2 backend. Since you mentioned "MDC" (of which I know nothing) I was wondering if you wanted to discuss what that was and how you thought it might work well with Flogger's Metadata. I'd be happy to look at adding it (especially if it can leave metadata more structured when it's handled by the backend).
from flogger.
I know nothing about Metadata., but to me, MDC looks very different. MDC is basically just a public static final ThreadLocal<Map<String, String>>
, which you put something in when you start some processing (and remove it afterwards) and - depending on the configuration - it gets printed with every log line automatically. Pretty trivial and pretty useful. I guess, it works with flogger when using a corresponding backend.
from flogger.
I've got something cobbled together on my end using a io.grpc.Context
and a custom logging backend to do similar. IIRC we'd had mixed luck with MDC because it's very thread-oriented, so it started falling apart for more complicated systems (e.g. we wanted breadcrumbs about the RPC that caused some complex multi-threaded code)
Unfortunately, it's a little awkward arbitrarily dealing with grpc Contexts & core flogger isn't going to want to pull in that kind of dependency. But maybe a way to teach flogger about arbitrary metadata suppliers would simplify doing something like that without going to the extreme of a custom backend?
from flogger.
Related Issues (20)
- Benchmarks and String Creation HOT 19
- Architecture diagram for flogger
- Extensibility How to HOT 9
- Better document Flogger's status (active, maintained, in use at Google) HOT 5
- Support for java.util.ResourceBundle HOT 9
- Add tags from thread context to log HOT 17
- Use java.time.Duration for atMostEvery in LoggingApi. HOT 2
- Flag --incompatible_disable_starlark_host_transitions will break Flogger in Bazel 7.0 HOT 6
- Release schedule?
- Default JavaDocs generated for Flogger confusingly suggest it's deprecated (it isn't). HOT 2
- How to handle ScopedLoggingContext for new Threads / ThreadPools? HOT 1
- Provide a log writer to produce JSON log items according to Elastic Common Schema HOT 8
- I don't believe ScopedLoggingContexts should obviously accept null "no-op" arguments. HOT 5
- Incorrect caller details logged with Flogger in spring boot HOT 2
- Error: 'JavaInfo' value has no field or method 'transitive_deps' HOT 5
- Error: 'JavaInfo' value has no field or method 'transitive_deps' HOT 5
- Next release HOT 2
- ThreadlocalRandom instead of ThreadLocal HOT 8
- java failed error executing Javac command from target //api:checks HOT 5
- test
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 flogger.