log4net:是否有一种简单的方法可以使用 HTTP POST 将错误日志发送到 URI?
我对 Log4Net 还很陌生(我使用了 log4j),我想知道将错误日志(错误或致命错误)发送到 URI 的最佳策略。服务器已设置并正在侦听。
我打算冒险重新发明轮子并扩展 AppenderSkeleton 类来创建 POSTAppender。有没有更简单的方法来做到这一点?
I'm pretty new to Log4Net (I used log4j), and I'm wondering the best strategy for sending error logs (on Error or Fatal Error) to a URI. The server's already set up and listening.
I was going to risk re-inventing the wheel and extend the AppenderSkeleton class to create a POSTAppender. Is there any easier way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有比这更简单的方法了。扩展
AppenderSkeleton
相当简单,我建议您尝试一下。您只需要重写一种方法,Append(LoggingEventloggingEvent)
。对于您的特定错误或致命要求,您可以在 log4net 配置中使用
threshold
设置或Filter
。作为参考,有一个 log4net 的内置附加程序列表。
There is not an easier way to do it. Extending
AppenderSkeleton
is fairly easy and I'd recommend trying your hand at it. There's only one method you're required to override,Append(LoggingEvent loggingEvent)
.For your specific Error or Fatal requirements, you could use a
threshold
setting or aFilter
in your log4net configuration.For reference, there is a list of built-in appenders for log4net.