Logging multiple instance application best practice?

后端 未结 2 616
你的背包
你的背包 2021-02-19 01:07

I finally tried log4net for my WPF desktop application.

I\'m struggling with the fact that RollingFileAppender has no built in support for multiple instance application

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 01:29

    Another option when you want to log to the rolling files and avoid risks of writing to the same log file is to programmatically change the name of the log4net log file path. For example, you could pass the log file name or some part of it as process start-up parameter and then set it from the code.

    Just make sure you do that path change before any logging occurs. Otherwise, similar configuration to the 'Multiple FileAppender with minimal locking' from the previous answer can be used.

提交回复
热议问题