Nlog - Generating Header Section for a log file

后端 未结 3 528
终归单人心
终归单人心 2020-12-06 06:32

Just recently got into experimenting with NLog, and it occurs to me that I would like to be able to add header information to the top a log file such as:

Exe         


        
3条回答
  •  庸人自扰
    2020-12-06 07:30

    Just happened to stumble on this while looking at replicating a header/footer in a log one of my co-workers created with log4net. I found this from some open-source project and adapted it as an internal example. I think it should be simple to modify for your needs.

    
      
        

    It gives me output that looks like this:

    ----------NLog Demo Starting---------
    
    2013-03-01 16:40:19.5404|INFO|Project.Form1|Sample informational message
    2013-03-01 16:40:19.5714|WARN|Project.Form1|Sample warning message
    2013-03-01 16:40:19.5714|ERROR|Project.Form1|Sample error message
    2013-03-01 16:40:19.5714|FATAL|Project.Form1|Sample fatal error message
    ----------NLog Demo Ending-----------
    

    I have no idea why this seems to be undocumented. The only reference I could find was here: https://github.com/nlog/NLog/wiki/LayoutWithHeaderAndFooter

    -Jody

提交回复
热议问题