Skip to content
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

Support NO_COLOR environment variable #154

Merged
merged 1 commit into from
Mar 17, 2024
Merged

Conversation

sungam3r
Copy link
Contributor

fixes #153

@nblumhardt nblumhardt merged commit 1c35ad9 into serilog:dev Mar 17, 2024
1 check passed
@nblumhardt
Copy link
Member

Awesome 👍

@sungam3r sungam3r deleted the nocolor branch March 18, 2024 05:34
@borland
Copy link

borland commented Mar 19, 2024

Thanks!

@nblumhardt nblumhardt mentioned this pull request Jun 9, 2024
@rcdailey
Copy link

rcdailey commented Jun 19, 2024

I tested this out but it doesn't work for me. Will this not work in combination with Serilog.Expressions?

EDIT: I ended up having to implement this manually, like so:

private ExpressionTemplate GetConsoleTemplate()
{
    var template = "[{@l:u3}] " + GetBaseTemplateString() +
        "{#if SanitizedExceptionMessage is not null}: {SanitizedExceptionMessage}{#end}\n";

    var raw = !string.IsNullOrEmpty(env.GetEnvironmentVariable("NO_COLOR"));
    return new ExpressionTemplate(template, theme: raw ? null : TemplateTheme.Code);
}

Again, I'm not sure if this is an issue specific to Serilog.Expressions, but this solution works for me.

@nblumhardt
Copy link
Member

👍 Serilog.Expressions has its own theming implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please support NO_COLOR environment variable
4 participants