Skip to content

Viewer fails to load CLEF files containing custom level names (Progress, Note, Outcome, Important) #977

@NameOfTheDragon

Description

@NameOfTheDragon

Describe the bug
Opening a CLEF file with events whose @l (level) is set to a non‑Serilog/custom value causes the viewer to throw an unhandled exception and return HTTP 500.
Example offending level values:

  • Info (NLog standard)
  • Progress
  • Note
  • Outcome
  • Important

Note: the @l property can contain different values depending on the logging framework used. NLog, for example, produces Info levels. When logging from NLog into Seq, it is possible to define custom log levels that can be any string value, such as the ones I regularly use listed above. Therefore, it would be highly desirable (in my opinion) to not restrict the severity levels to those defined by Serilog.

Seq internally accepts a number of different string matches for each of the standard levels, for example, the filter for "informational" is defined as:

@Level in ['i', 'in', 'inf', 'info', 'inform', 'information', 'informational', 'norm', 'normal'] ci

This, it works well with SeriLog, NLog and other platforms.

To Reproduce

  1. Export logs from Seq to CLEF, including entries with custom level names in @l. I have attached a small sample, exported from Seq, in GitHub-977-clef-sample.clef.json (note: the original extensions was .clef but GitHub would not accept that as an upload, so I added the .json)
  2. Open the CLEF file in Compact Log Format Viewer.
  3. Observe that loading fails.

Minimal reproducer:

{"@t":"2025-01-21T16:04:30.5308432Z","@mt":"Initializing test context","@l":"Progress"}

Actual console output:

System.ArgumentException: Requested value 'Progress' was not found.
    at System.Enum.Parse(...).
    at Serilog.Formatting.Compact.Reader.LogEventReader.ReadFromJObject(...).
    ...
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
    Request finished ... 500 - text/plain;+charset=utf-8

Expected behavior
The viewer should tolerate unknown/non‑SeriLog @l values, perhaps by:

  • Accepting the Custom/non-SeriLog values from the clef file and not attempting to parse them as an enum.
  • Mapping them to a default level (e.g., Information) and preserving the original string in another property, or
  • Using an approach like Seq where the user can specify multiple values to be mapped to a standard level,
  • Displaying them with a neutral/default style,
    …without aborting the entire load.

Screenshots / sample data
A real‑world example CLEF line (values redacted except for level fields):

{"@t":"2025-01-21T16:04:30.5308432Z","@mt":"Initializing test context","@i":"2896a451","@l":"Progress","Machine":"...","SeqLevel":"Progress", "...": "..."}

Environment:

  • Compact Log Format Viewer version: [your version here]
  • OS: [e.g., Windows 11 23H2]
  • .NET runtime: [e.g., .NET 8.0.7]
  • Install method: [release binary / source build]
  • Log source: Seq with custom severity levels (configured via NLog.config)

Additional context
Seq supports custom severity levels and serialises them into CLEF, but the viewer’s parser appears to pass the @l string directly to Enum.Parse() on a fixed set of known level names. An unrecognised string throws an ArgumentException, aborting the entire file load on the first offending entry.

Possible fixes

  • Wrap enum parse in try/catch and fall back to a safe default.
  • Extend supported enum set to include user‑defined levels.
  • Skip events with unsupported levels but continue loading remaining events.
  • Preserve original @l and/or SeqLevel in the parsed model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions