log4net - Appenders not working in IIS7.5

前端 未结 7 1098
再見小時候
再見小時候 2020-11-29 06:39

I am able to write to a log file using log4net and Cassini/IIS dev server, but when I use IIS7.5, I can\'t write out to a file.

Initially, I got a security exception

相关标签:
7条回答
  • 2020-11-29 07:25

    Use a tool like Process Monitor and spy on the IIS process. I suspect it is trying to create the log file in a directory the IIS account has no access to.

    Following on from that test, specify an absolute path to the log file that you know the IIS process has access to.

    0 讨论(0)
  • 2020-11-29 07:26

    Try giving IIS AppPool\DefaultAppPool user full permission to the log directory. That has helped me at least once.

    0 讨论(0)
  • 2020-11-29 07:27

    I finally got it working, i added

    <trust level="Full" />
    

    to system.web.

    With medium, the AdoNetAppender stops working, but the FileAppender still works for medium and high.

    0 讨论(0)
  • 2020-11-29 07:36

    Give full right to these iis users.

    1. IUSR
    2. IIS_IUSR (PC_Name/IIS_IUSRS)
    0 讨论(0)
  • 2020-11-29 07:37

    I had this same problem. I solved it by changing the IIS 7 configuration. Rather easy...

    Go to the application pool advanced settings and set "Load User Profile" to true! Then make sure that IUSR (IIS user) have permission to write to the logs path.

    Additionally, usually, I add support for 32 bit applications, this is useful when you download and use assemblies from 3rd parties, where you don't know if they were complied for 32, 64 or independent.

    I found this by reading this article: http://learn.iis.net/page.aspx/624/application-pool-identities/

    Best regards, Tiago.

    0 讨论(0)
  • 2020-11-29 07:41

    Did you go into windows explorer and check the correct users (NETWORK SERVICE ?) have write permissions?

    0 讨论(0)
提交回复
热议问题