Applications that need to log to a local file can write them in JSON format for easy importing into Seq.
Both newline-delimited JSON and plain-text log files can be imported into Seq using the Command-line Client's
seqcli ingest command.
The recommended format is Compact Log Event Format, produced by tools including Serilog.Formatting.Compact.
The easiest way to import logs is through
seqcli ingest -i log-*.txt --json --filter="@Level <> 'Debug'" -p Environment=Test
Logs can be imported from a file (
-i <filename>), or ingested in real-time from
The following options are supported:
|File to ingest, including the |
|Specify how invalid data is handled: |
|Specify name/value properties, e.g. |
|An extraction pattern to apply to plain-text logs (ignored when |
|Read the events as JSON (the default assumes plain text)|
|Filter expression to select a subset of events|
|A message to associate with the ingested events; https://messagetemplates.org syntax is supported|
|The level or severity to associate with the ingested events; this will override any level information present in the events themselves|
|Specify how connection failures are handled: |
|The URL of the Seq server; by default the |
|The API key to use when connecting to the server; by default the |
|A connection profile to use; by default the |
For more information, including the syntax for plain text parsing, see the detailed instructions.
The most common way to create CLEF files is by specifying
CompactJsonFormatter when configuring a Serilog sink, for example the file sink.
This must be installed from NuGet first:
Install-Package Serilog.Sinks.File Install-Package Serilog.Formatting.Compact
The formatter is passed either in C# configuration:
Log.Logger = new LoggerConfiguration() .WriteTo.File(new CompactJsonFormatter(), "./logs/myapp.json") .CreateLogger();
Or via XML
<appSettings> <add key="serilog:using:File" value="Serilog.Sinks.File" /> <add key="serilog:write-to:File.path" value="./logs/myapp.json" /> <add key="serilog:write-to:File.formatter" value="Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact" />
Updated 8 months ago