无法获取log4net的在我们的WCF应用程序的工作 [英] Can't get Log4Net to work in our WCF application

查看:127
本文介绍了无法获取log4net的在我们的WCF应用程序的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试使用log4net的从我们的IIS 6部署WCF应用程序登录。我们试图记录到一个文件,但似乎无法获取要创建的日志文件,更不用说看到其中的日志输出。从web.config中的相关部分是:



 < sectionGroup名称=通用> 
<节名称=记录TYPE =Common.Logging.ConfigurationSectionHandler,Common.Logging/>
< / sectionGroup>

<普通>
<&记录GT;
< factoryAdapter TYPE =Common.Logging.Simple.TraceLoggerFactoryAdapter,Common.Logging>
<精氨酸键=级别值=INFO/>
<精氨酸键=showLogNameVALUE =真/>
<精氨酸键=showDataTimeVALUE =真/>
<精氨酸键=dateTimeFormatVALUE =YYYY / MM / DD HH:MM:SS:FFF/>
< / factoryAdapter>
< /记录>
< /&常见GT;

<&log4net的GT;
<追加程序名称=FileAppenderTYPE =log4net.Appender.RollingFileAppender>
< PARAM NAME =文件VALUE =C:\logs\ApplicationInfoTest.log/>
<阈值=INFO/>
< PARAM NAME =AppendToFileVALUE =真/>
< PARAM NAME =DatePatternVALUE =DDMMYYYY/>
< PARAM NAME =MaxSizeRollBackupsVALUE =10/>
< PARAM NAME =MaximumFileSizeVALUE =10MB/>
< PARAM NAME =RollingStyleVALUE =大小/>
< PARAM NAME =StaticLogFileNameVALUE =真/>
<布局类型=log4net.Layout.PatternLayout>
< PARAM NAME =头价值=\r\\\
\r\\\
----------------------- ---------------------- \r\\\
/>
< PARAM NAME =页脚值=\r\\\
----------------------------- ---------------- \r\\\
\r\\\
/>
< PARAM NAME =ConversionPattern值=%D [%T]%-5p - %M%N/>
< /布局>
< /附加器>
<根和GT;
<电平值=INFO/>
<附加目的地-REF REF =FileAppender/>
< /根>
< / log4net的>

通过这个配置,我们可以看到信息级别的日志出来我们的应用程序使用DebugView中时,却是显然,这是从

片,而不是


片。



有什么,我们已经没有成立在web.config中?它是一个权限问题与我们已经创造了日志写入到目录?



请指出我们的明显错误。


< DIV CLASS =h2_lin>解决方案

使用的ProcessMonitor从Sysinternals的,以找出权限被拒绝




(可能你可以通过附加一个调试器和诱捕例外,而不是仅我的代码确定相同的信息)

您确保该服务在其下运行的过程中有你想要写?


的文件夹的权限

We are trying to use Log4Net to log from our IIS 6-deployed WCF Application. We are trying to log to a file, but can't seem to get the log files to be created, let alone see the logging output in them. The pertinent pieces of out web.config are:

<sectionGroup name="common">
    <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
...
<common>
    <logging>
        <factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
            <arg key="level" value="INFO" />
            <arg key="showLogName" value="true" />
            <arg key="showDataTime" value="true" />
            <arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
        </factoryAdapter>
    </logging>
</common>

<log4net>
    <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
        <param name="File" value="c:\logs\ApplicationInfoTest.log" />
        <threshold value="INFO" />
        <param name="AppendToFile" value="true" />
        <param name="DatePattern" value="ddMMyyyy" />
        <param name="MaxSizeRollBackups" value="10" />
        <param name="MaximumFileSize" value="10MB" />
        <param name="RollingStyle" value="Size" />
        <param name="StaticLogFileName" value="true" />
        <layout type="log4net.Layout.PatternLayout">
            <param name="Header" value="\r\n\r\n---------------------------------------------\r\n" />
            <param name="Footer" value="\r\n---------------------------------------------\r\n\r\n" />
            <param name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
        </layout>
    </appender>
    <root>
        <level value="INFO" />
        <appender-ref ref="FileAppender" />
    </root>
  </log4net>

With this configuration we can see INFO level logging coming out of our application when using DebugView, but it is clear that this is from the piece and not the
piece.

Is there something that we have failed to set up in web.config? Is it a permissions issue with the directory we have created for the logs to be written to?

Please point out our obvious mistake.

解决方案

Use ProcessMonitor from SysInternals to find out where permissions are being refused

(Potentially you can determine the same info by attaching a debugger and trapping on exceptions, not in Just My Code)

Are you sure that the process under which the service is running has permissions on the folder you're trying to write to?

这篇关于无法获取log4net的在我们的WCF应用程序的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆