I have a log file I am trying to get some info out of. The information I need is on the line prior to last line and also the very last line is/could be blank. So it is actually line before last line or two before last line if last line is blank.
I know how to get to last line of the file using:
var lastLine = File.ReadLines("SomeFile.log").Last();
I can also use Linq to skip lines using .skipWhile() or .skip(1) but not going backward.
I am not sure how to get to the line I need. This is a sample of last few lines of the log file (with last line being blank):
2021/05/02 23:47:57:008989 send_status_message(2) Info: "Stream status heartbeat sent: [SY 1.3.2 ]"
2021/05/02 23:47:57:225172 send_status_message(2) Info: "Received heartbeat response: [S ]"
2021/05/03 00:00:00:045055 set_log_dir(2) Info: "Changing log directory to /abc/def/logs/2021-05-03."
<blank-line>
I am trying to get the timestamp on that line (i.e. 2021/05/02 23:47:57:225172).