如何跟踪log4net的问题 [英] How to track down log4net problems
问题描述
我用log4net的所有的时间,但有一点我从来没有想通了,是如何分辨什么在里面怎么回事。例如,我有一个控制台附加目的地,并在我的项目数据库的appender。我做了一些更改数据库和code,而现在的数据库附加器不工作了。我会找出原因,最终,但它会帮助很多,如果我可以看到这是怎么回事里面log4net的。
I use log4net all the time, but one thing I've never figured out is how to tell what's going on on the inside. For example, I've got a console appender and a database appender in my project. I made a few changes to the database and the code, and now the database appender doesn't work anymore. I'll figure out why eventually, but it would help a lot if I could see what's going on inside log4net.
请问log4net的生成任何类型的输出,我可以看到,尝试确定我的问题的根源?
Does log4net generate any kind of output that I can view to try to determine the source of my problem?
推荐答案
首先,你必须在应用程序配置文件中设置这个值:
First you have to set this value on the application configuration file:
<configuration>
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
</appSettings>
</configuration>
然后,确定要救你可以在同一个config文件中添加以下code的输出文件:
Then, to determine the file in which you want to save the output you can add the following code in the same .config file:
<configuration>
...
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add
name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\tmp\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>
...
</configuration>
您可以找到更详细的解释寻找 我怎么能log4net的内部调试? 在log4net的常见问题页面:
You can find a more detailed explanation looking for 'How do I enable log4net internal debugging?' in the log4net FAQ page:
<一个href="http://logging.apache.org/log4net/release/faq.html">http://logging.apache.org/log4net/release/faq.html
这篇关于如何跟踪log4net的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!