如何让 log4net 在本地计算机上与 Chainsaw 配合使用
我想将 log4net 的 UdpAppender 与 Apache Chainsaw 结合使用来记录来自 ASP.NET Web 应用程序的消息。 我按照 log4net 网站上的说明进行操作,但没有发送 UDP 数据包(防火墙已关闭,我尝试使用 TcpView 监视我的计算机 - 根本没有生成 udp 数据包;其他附加程序正在工作)。 Log4net 调试不会给出任何错误,UdpAppender 被添加到记录器中。我不知道我错过了什么。
我的配置文件是:
<log4net debug="true">
<renderer renderingClass="Logging.HttpContextRenderer" renderedClass="System.Web.HttpContext" />
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<localPort value="8080" />
<remoteAddress value="127.0.0.1" />
<remotePort value="8080" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="UdpAppender"/>
</root>
</log4net>
I would like to use log4net's UdpAppender with Apache Chainsaw to log messages from my ASP.NET web application.
I followed instructions on log4net's website, but no Udp packets are sent (firewall is turned off, and I tried to monitor my machine with TcpView - no udp packets were generated at all; other appenders re working). Log4net debug doesn't give any errors, UdpAppender gets added to loggers. I don't know what I am missing.
My config file is:
<log4net debug="true">
<renderer renderingClass="Logging.HttpContextRenderer" renderedClass="System.Web.HttpContext" />
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<localPort value="8080" />
<remoteAddress value="127.0.0.1" />
<remotePort value="8080" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="UdpAppender"/>
</root>
</log4net>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是使用 log4net udp 附加程序遇到类似问题的人的存档:
http://www.mail-archive.com/ [email protected]/msg03906.html
您可以将 Chainsaw V2 与常规文本一起使用文件,如果这样会更容易(使用 VFSLogFilePatternReceiver )。
《电锯》的新版本即将发布,其中包含大量增强功能。预发布版本和屏幕截图可在此处获取:
http://people.apache.org/~sdeboy /
Here's an archive of someone with similar issues using the log4net udp appender:
http://www.mail-archive.com/[email protected]/msg03906.html
You can use Chainsaw V2 with a regular text file if that would be easier (using VFSLogFilePatternReceiver).
A new version of Chainsaw will be released shortly with a lot of enhancements. A pre-release version and screen shot are available here:
http://people.apache.org/~sdeboy/
我也遇到了同样的问题,发现删除
就解决了。
我使用 log4net UdpAppender 页面上的示例测试了附加程序: http ://logging.apache.org/log4net/release/sdk/log4net.Appender.UdpAppender.html
但我不得不将该行更改
为
如果您使用此,您可以简单地将收到的消息重写到滚动日志文件使用 log4net,我相信 Chainsaw 可以读取它。
这也可能有效: http://devintelligence.com/log4netviewer/
如果这不起作用,你可以调试log4net,或者使用本文提到的内部记录器机制:
Log4Net 有效在开发计算机上,部署到共享主机(使用相同的 db/connstring)时失败以解决任何进一步的问题。
I also had the same problem and found that removing the
solved it.
I tested the appender using the example on the log4net UdpAppender page: http://logging.apache.org/log4net/release/sdk/log4net.Appender.UdpAppender.html
but I had to change the line
to
If you use this, you can simply rewrite the received messages to a rolling logfile using log4net and I believe Chainsaw can read that.
This might work as well: http://devintelligence.com/log4netviewer/
If this doesn't work, you can debug log4net, or use the internal logger mechanism mentioned in this article:
Log4Net works on Dev machine, fails when deployed to shared host (using same db/connstring) to troubleshoot any further problems.