I need to write some information related to the status of the application that is launched via system scheduler. Then the processing lines should follow:
2019-10-09 23:39:22.936 +02:00 [DBG] ======================================================================
2019-10-09 23:39:22.999 +02:00 [DBG] MyAppDELFOR (0.10.1 2019-10-09)
2019-10-09 23:39:22.999 +02:00 [DBG] ----------------------------------------------------------------------
2019-10-09 23:39:23.015 +02:00 [DBG] stageDirectory: 'c:\EDIAbc\Company_received_stage'
2019-10-09 23:39:23.015 +02:00 [DBG] oftpIncomingDirectory: 'c:\EDIAbc\Company_incoming'
2019-10-09 23:39:23.015 +02:00 [DBG] archiveDirectory: 'c:\EDIAbc\Company_received_archive'
2019-10-09 23:39:23.015 +02:00 [DBG] ----------------------------------------------------------------------
2019-10-09 23:39:23.061 +02:00 [WRN] The stage file 'c:\EDIAbc\Company_received_stage\DELFOR_010091_20191001' already exists and is to be deleted.
2019-10-09 23:39:24.905 +02:00 [INF] Processing 'c:\EDIAbc\Company_received_stage\DELFOR_010086_20191001'
2019-10-09 23:39:30.281 +02:00 [INF] Processing 'c:\EDIAbc\Company_received_stage\DELFOR_010087_20191001'
2019-10-09 23:39:34.109 +02:00 [INF] Processing 'c:\EDIAbc\Company_received_stage\DELFOR_010088_20191001'
Currently, I always write the header. However, the application is launched rather frequently, and the case when "No data to process" is rather usual. Because of that I would like to avoid writing the header, and I would like to write just "No data to process" or the like line.
Is there any way (in Serilog) to write the header only when the log file is created?
A set of hooks that enable such a facility have been added to the File sink recently. The main contributor has a nice demo repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With