Open christophekumor opened 5 years ago
in most case i see people use this to log the environment/context Version of powershell, path of script, current user, etc...
I would keep the header and footer parsable. example
<datetime> <delimiter> <messagetype> <delimiter> <source><delimiter><message>
example:
2019/06/25.08:34:00UTC;INF;HEADER;Using PowerShell version: 6.2
2019/06/25.08:34:01UTC;INF;HEADER;current user: mydomain\lazywinadmin
2019/06/25.08:34:01UTC;INF;MAIN; define var....
2019/06/25.08:34:01UTC;INF;MAIN; connect to db
2019/06/25.08:34:01UTC;INF;MAIN; perform task
2019/06/25.08:34:01UTC;INF;MAIN; done
2019/06/25.08:34:01UTC;INF;FOOTER; script completed in 1sec
ok for a header but as proposed @lazywinadmin with the same format as the log itself. I hate having a log with header, log then footer :-) like that
i don't like Header Using PowerShell version: 6.2 current user: mydomain\lazywinadminc
2019/06/25.08:34:01UTC;INF;MAIN; define var.... 2019/06/25.08:34:01UTC;INF;MAIN; connect to db 2019/06/25.08:34:01UTC;INF;MAIN; perform task 2019/06/25.08:34:01UTC;INF;MAIN; done
Footer script completed in 1sec
The main problem here is that we create a fixed format. We should have a dynamic format or at least a format we can extend to use other log containers like Json, Win Event ...
as i said i don't like header and footer on log file so for me is not useful ;-)
Param to add a header to the log file.
we'll have to define what we want in this header.