serilog / serilog-sinks-file

Write Serilog events to files in text and JSON formats, optionally rolling on time or size
Apache License 2.0
333 stars 117 forks source link

How to read txt files into memory? #288

Closed Cloud33 closed 1 year ago

Cloud33 commented 1 year ago

I want to read the log file generated by serilog:

2023-05-21 00:42-58.572 [INF] txt1
2023-05-21 00:42-58.619 [INF] txt1
2023-05-21 00:43-00.478 [INF] Get txt1
2023-05-21 00:43-00.494 [INF] Set txt1

The output template I am using: {Timestamp:yyyy-MM-dd HH:mm-ss.fff }[{Level:u3}] {Message:lj}{NewLine}{Exception}

How can I quickly read log files and format them?

Thank you

cocowalla commented 1 year ago

Reading Serilog log files is no different than reading any other text-based file - for example, use StreamReader and parse line-by-line.

It's not clear what you mean about formatting, but I think this question would better belong on StackOverflow, where it's likely to get far more eyeballs on it 👍