使用Nxlog和Log4net进行日志记录 [英] Logging with Nxlog and Log4net

查看:128
本文介绍了使用Nxlog和Log4net进行日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开展一个项目,我正在使用Log4net从应用程序收集日志信息并将信息写入文件。我正在使用Nxlog监视此文件,解析文件中包含的信息,并将信息发送到所有所需位置,即Loggly等。到目前为止我读过的所有内容都说Nxlog要么从网络连接或文件中收集日志信息,我很好奇Nxlog是否可以监控应用程序来收集这些日志信息。任何帮助将不胜感激。谢谢。

I am currently working on a project where I am collecting log information from an application using Log4net and writing the information to a file. I am using Nxlog to monitor this file, parse the information contained in the file, and send the information to all of the desired locations, i.e. Loggly,etc. Everything that I have read thus far says that Nxlog either gathers log information from a network connection or from a file, I am curious as to whether Nxlog can monitor an application to gather this log information. Any help will be greatly appreciated. Thank you.

推荐答案

您好,



不,它不能用作应用程序监控工具。 NXLOG是一个通用的日志收集器和转发器。虽然在服务器模式下运行,但应用程序可以通过syslog将日志信息路由到NXLog实例。对于应用程序监控,您可能需要尝试 Hyperic Application&系统监控 [ ^ ]



问候,
Hello,

No, it can not be used as a application monitoring tool. NXLOG is a universal log collector and forwarder. Although when run in server mode application can route the log information to NXLog instance via syslog. For application monitoring you may want to try Hyperic Application & System Monitoring[^]

Regards,


log4net:

log4net:
...
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
  <remoteAddress value="localhost" />
  <remotePort value="5561" />
  <layout type="log4net.Layout.SerializedLayout, log4net.Ext.Json">
  </layout>
</appender>
...





您好,请将您的log4net日志记录到nxlog正在侦听的本地UDP端口。为了简化解析,您可以使用我的项目 log4net.Ext.Json 添加JSON格式。像这样,您将跳过不必要的文件记录并从磁盘IO中解除应用程序。运行具有比日志记录应用程序更高优先级的nxlog进程将确保它在UDP上具有优势,因此即使在压力很大的情况下也可以防止丢失日志。



nxlog:



Hi, make your log4net log to a local UDP port where nxlog is listening. To simplify parsing you may add JSON formatting with my project log4net.Ext.Json. Like that, you'll skip the unnecessary file logging and relieve the application from disk IO. Running nxlog process with a higher priority than the logging app will ensure it has the upper hand on UDP and hence prevent losing logs even under heavy stress.

nxlog:

...
<Extension json>
    # We expect JSON on the UDP input, this module provides parse_json()
    Module  xm_json
</Extension>

<Input udpjson>
    # Listen on local UDP port for JSON events
    Module      im_udp
    Host    localhost
    Port    5561
</Input>
...


这篇关于使用Nxlog和Log4net进行日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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