Is There a Key-Based Logging System Out There?
Asked by
CuriousCoder92
I'm trying to enhance my logging system and came up with a concept that seems like it should already exist, but I can't find anything resembling it. Has anyone encountered something similar or know what it might be called?
The idea is to shift from inline logging to a more centralized storage method. For instance, instead of logging something like:
```
log("Success", ['portal','api'], 'task', "Sales numbers are constant, proceeding to report")
```
I envision using a key-based approach like this:
```
log(**gen_kwargs("20.PA.E.2429030A"))
```
Where a database keeps track of the details for the key like this:
```
{
'20.PA.E.2429030A':{
'message':'Sales numbers are constant. Proceeding to report',
'destination': ['portal','api'],
'layer': 'event',
'status_code': 20,
'date_created': "2024-10-15",
'user_attribution': '[email protected]'
}
}
```
The pros of this method include author tracking, version control, and the ability to dynamically update messages. However, the drawbacks are the need for a centralized infrastructure and the added complexity to the code.
It could be a middle-ground approach where key data isn't entirely random and still holds important information. I'm curious whether this kind of mechanism has already been developed or if there's a specific term for it.
Answers
I've built a custom logging library that allows for dynamic changes in log levels and destinations, like JSON and SQLite, which works great. Sure, syncing logs can complicate things, but itโs manageable.
Reply to this answer
Have you checked out OpenTelemetry? It might give you the framework you need for a centralized logging approach!
Reply to this answer
I think what you're trying to do is awesome. Iโve seen similar setups in past jobs, but they were usually custom-built. It might be worth keeping control of your logging to cater to your specific needs.
Reply to this answer
What you're describing sounds a lot like structured logging. It allows you to log in JSON or logfmt formats, making it easier to organize and send logs to a central storage. Tools like Logstash and Vector can help convert and enrich those logs too.
Reply to this answer
Check out New Relic; they have a centralized logging service that might align with what you're envisioning! It could be just what you need for your setup.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions