datalust / seq-tickets

Issues, design discussions and feature roadmap for the Seq log server
https://datalust.co/seq
96 stars 5 forks source link

For non-standard event Level, unexpected CSS classes are applied. #2162

Closed NameOfTheDragon closed 5 months ago

NameOfTheDragon commented 5 months ago

Describe the bug I'm using a brand new feature introduced in NLog.Targets.Seq 4.0.0 just recently that allows the log event level to be set to something other than the NLog "cast-in-stone" severity levels. This uses an additional property, in my case named "SeqLevel" which (if present) NLog.Targets.Seq uses to overwrite the NLog level before sending to Seq. Then in Seq I am able to generate events with "Note" severity like this one:

image

My NLog configuration to achieve this looks like this:

      <target xsi:type="Seq" serverUrl="xxx" apiKey="xxx" seqLevel="${event-properties:SeqLevel:whenEmpty=${level}}">

And in code, the log event is written like so:

        Log.Info()
            .Message("Program start - correlation id {correlationId}", CompositionRoot.CorrelationId)
            .Property("Version",    GitVersion.GitInformationalVersion)
            .Property("SemVer",     GitVersion.GitFullSemVer)
            .Property("GitCommit",  GitVersion.GitCommitSha)
            .Property("CommitDate", GitVersion.GitCommitDate)
            .Property("SeqLevel",   "Note")
            .Write();

This all works great, and generates the "Note" log event. However, the CSS classes rendered for that event do not match the level. Inspecting in Edge Dev Tools, we have: image

I expected that to be seq-level-note not seq-level-information. There's no reference to my note level in the CSS. The whole point, or at least the main point, of this new feature was to be able to format entries based on levels that couldn't normally be generated by NLog, and that purpose is defeated by the HTML element not having the expected CSS classes

Related items: https://github.com/datalust/seq-tickets/discussions/2117 https://github.com/datalust/nlog-targets-seq/pull/75 https://github.com/datalust/seq-tickets/discussions/1996

Expected behavior Seq should add a CSS class based on the actual log event level and not default to seq-level-information.

Environment (please complete the following information):

nblumhardt commented 5 months ago

Thanks for the report, Tim, we'll include the fix in the upcoming 2024.3 build.