log4net - Appenders not working in IIS7.5

前端 未结 7 1099
再見小時候
再見小時候 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:43

    You can enable log4net internal debugging by adding the key log4net.Internal.Debug to your application configuration file.

    <appSettings>
        <add key="log4net.Internal.Debug" value="true"/>
    </appSettings>
    

    This will write debug messages to the console and the System.Diagnostics.Trace system. You can then log these messages to a text file by adding a trace listener to you configuration file. Make sure the application has permission to write to the file.

    <system.diagnostics>
        <trace autoflush="true">
            <listeners>
                <add 
                    name="textWriterTraceListener" 
                    type="System.Diagnostics.TextWriterTraceListener" 
                    initializeData="C:\tmp\log4net.txt" />
            </listeners>
        </trace>
    </system.diagnostics>
    

    Alternatively, trace messages are also written to the system debugger, so you can use a utility like DebugView to capture the messages. See the log4Net FAQ for more details.

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