-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme for coloring all line #35
Comments
Hi @Lukino2000 - no, this isn't possible in the current version of the sink. Just to gauge interest - how important is the line coloring for you/your app? It's possible we could extend the theming system to support it, but there aren't all that many possible themes that can be created using this mechanism so we've held off on attempting this so far. |
While I personally don't have a need for coloring lines, I'd like to be able to change the output color for an individual log event, such as coloring certain currency logs different colors (for example -- to make it easier to distinguish between GBP and USD), without having to create a theme. |
I'd love to see this, i.e. the whole line using the color of the level used, it would make the output much easier to read. I would never use the ability to customize the color of a single line, but colorizing parameters would be great, e.g. highlighting the exception class, a correlation ID, a server IP etc. |
This is a nice to have feature for a console application currently under development: I'm using Serilog to write execution status info to the output console with this simple template: |
This is exactly my use case too. For short-running applications this makes sense - esp. when you want to use a single framework to logging into file and having a nice formatted console output for the user. |
I haven’t been back for a while, but I did a spike on making the template token renderer public. I was attempting to see how a few different proposed features might work here: dev...adamchester:spike-themed-exception Edit: this has an example of how to colour lines by log level |
Righto, thanks for all the input! If anyone's keen to discuss design options, with a view to submitting a PR, I can help figure out how we can get this in 👍 |
I'd like to take a look at that @nblumhardt Because of the specific by level and extensibility there must be some hierarchy, so that when something isn't specified, it has to have some fallback value. (e.g. And by extensibility I mean, that it would also support variables from enrichers like I am still thinking what algorithm and data structure to use for it internally so that it is most efficient. It has to have possibly O(1) speed access with as little constant coeficient as possible. |
May I... up this? 👀 |
One more up vote from me! We are using serilog for a dotnet global tool so we can write to multiple sinks and it'd be useful to colorize the entire log line, in addition the background color of a log line when writing to the console. |
For those watching, we were able to implement a naive version that supports structure and full line colorization that meets our requirements using the following code. To support customized colorization at just the level or just the log line, you'd likely need your own implementation(s) of ITextFormatter which colorize the variety of parts. I'm certain that someone could generalize this to make it more broadly applicable using a them instead of hardcoding colorization requirements. Hope this helps the next person who needs this!
And the extension method to enable it:
|
I wrote an extension to accomplish this. I don't know if this is better or worse than the code above, but anyone is free to use it. It will accept colors. As written it only supports logging at information level. Output looks like this:
Complete code at this gist: |
is there anyway to obtain an output like this using theme?
The text was updated successfully, but these errors were encountered: