如何为我们在服务器上开发和运行的应用程序配置 log4net?

发布于 2024-09-07 22:32:01 字数 288 浏览 5 评论 0原文

如果有人能澄清我的困惑,我将不胜感激。我正在一家公司实习,该公司在 .NET 框架中开发和监控预付费重载系统,我们目前使用 C#,我需要研究 log4net 并帮助他们将其日志记录框架从简单日志记录提升到带有多个附加程序的高级日志记录和布局。到目前为止,我被告知要调查 log4net。我阅读了教程,基本上我是使用控制台应用程序和简单的网络应用程序完成的,但问题是当我运行应用程序时会发生日志记录,而我不希望这样,因为应用程序已经在服务器上运行。有人好心告诉我一种无需调试应用程序并使其登录入口点即可完成日志记录的方法。我很困惑,因为对整个事情都很陌生。提前致谢

I would really apreciate if some one kindly clarify my confusion. I'm doing my internship in a company that develops and monitors prepaid reload systems in .NET framework and we are using C# currently, and i am required to research log4net and help them elevate their logging framework from simple logging to advanced logging with several appenders and layouts. So far i been told to investigate log4net. I read tutorials and basicaly i done it with console app and also simple web app, but the problem is the logging happens when i run the application and i dont want that since the applications are already running on a server. some one kindly tell me a way to acomplish the logging without needing to debug the applications and making it log on entry point. I'm pretty much confused coz am new to the whole thing. Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尐籹人 2024-09-14 22:32:01

您需要构建的是一个接收器。 Log4net 有一个插件架构,支持您所描述的内容。更多文档在这里:

http://logging.apache.org/log4net/release /manual/plugins.html

摘录:
RemoteLoggingServerPlugin

创建一个远程日志接收器,可以
接收来自 a 的日志记录事件
远程处理Appender。创建远程处理
日志接收器。单个参数必须
被传递给构造函数
指定接收器 URI。这是一个名字
用于识别日志接收器
通过远程处理发布的对象,并且必须
事先与客户达成一致
可以进行通信。

用法示例:

LogManager.GetRepository().PluginMap.Add
  (new RemoteLoggingServerPlugin("LoggingSink"));

What you need to build is a receiver. Log4net has a plugin architecture which supports what you are describing. More documentation is here:

http://logging.apache.org/log4net/release/manual/plugins.html

Excerpt:
RemoteLoggingServerPlugin

Creates a remote logging sink that can
receive logging events from a
RemotingAppender. Creates a remoting
logging sink. A single parameter must
be passed to the constructor that
specifies the sink URI. This is a name
used to identify the logging sink
object published via remoting and must
be agreed with the client before
communication can take place.

Example usage:

LogManager.GetRepository().PluginMap.Add
  (new RemoteLoggingServerPlugin("LoggingSink"));
难得心□动 2024-09-14 22:32:01

如果他们希望您使用 log4net,他们会很乐意在服务器上重新启动更新的程序。毕竟,您需要将日志记录实际添加到您想要记录的程序中。

这样,如果您使用 log4net 配置文件,您的程序将侦听该文件,并且您可以随时更改它,而无需重新启动或重新编译应用程序。这会立即生效,因此您可以获得很大的灵活性。

如果您想集中监控事物,您可能会考虑将所有内容记录到数据库中。我使用 Log4View(商业程序)及其 TCP 远程处理,这很好。

If they want you to use log4net, they'd be happy to restart an updated program on the server. After all, you'll want to actually add logging to the program you want logged.

With that, if you're using a log4net configuration file, your program will listen to that file and you can change it whenever you want without restarting or recompiling the application. This goes into effect immediately, so you get great flexibility.

If you want to monitor things centrally, you might consider logging everything to a database. I use Log4View (commercial program) with their TCP remoting, which is nice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文