Why is the date appended twice on filenames when using Log4Net?

前端 未结 6 569
北荒
北荒 2021-02-01 18:52

I was trying to add the date to my log file name and I was able to make it work by following the few suggestions I\'ve found in stackoverflow. Everything works fine but for some

6条回答
  •  鱼传尺愫
    2021-02-01 19:03

    This happens if there is a problem accessing the log file when you initialize the log system. It can happen if you initialize the log system twice, if you run your program while another copy is running and writing to the log file, or if you are editing the log file in a text editor. Basically anything that causes a write lock on the log file when log4net init runs.

    Check your code for duplicate calls to log4net init - perhaps you are initializing in a constructor instead of in a singleton's static constructor or global init, for example.

    This can also happen if you are running in a 'web garden' configuration and don't include the PID in the filename, because each different web server process tries to write to the same file. If using web gardens and writing to files, add the pid to the filename pattern so each server process gets its own file.

提交回复
热议问题