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

前端 未结 6 581
北荒
北荒 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:01

    It's a permission problem. At least that's what's happening to me.

    I'm new in using Log4Net so I didn't know that it has internal logging but I found it so I tried turning internal logging on. I wasn't very sure what it's saying but here's what it looks like to me it's doing: 1. Append the date to the file name. 2. Try to access the file to write to it (failed). 3. Append the date to the file name again. 4. Successfully access the file (which has the weird file name now)

    Before I know this, I was google-ing for the solution to this problem with keywords like what I have as a title on this stackoverflow question. There wasn't that much information out there. I found maybe one guy who said it happens to some people but never really explained why nor the solution. With this new information (+the internal error message from Log4Net), I was looking at different threads from the search engines. With that I found hints that it might be a permission problem.

    It seems that the writing application doesn't have sufficient permission to the logs folder. The default identity of the application is usually NETWORK_SERVICE. After I give more permission (I gave it full control but i don't know what is the minimum to make it work) to the folder, it works just fine.

    If anyone can explain this better than me, please feel free to edit.

提交回复
热议问题