log4net 卡住了 &世界碳纤维
我在企业系统中使用 log4net
,该系统具有三层:
- API
- 内部通知
- 与第 3 方集成:外部通知
这些层通过 WCF (wsHttpBinding
) 相互通信,并且每层都有一个日志文件。 当我运行测试工作流程时,每个层都执行其工作,但记录器没有写入任何内容。
有什么想法吗?
I am using log4net
in an enterprise system, the system have three tiers:
- API
- Internal Notifications
- Integration to 3rd party: External Notifications
The layers talk each other via WCF (wsHttpBinding
) and in each layer there is a log file.
When I run a test workflow, each tier executed his job but the logger did not write anything.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下是一些想法:
在每个层中,您是否调用了
log4net.Config.XmlConfigurator.Configure(...)
?在大多数情况下,人们使用程序集属性在 AssemblyInfo.cs/Program.cs/Global.asax.cs/etc 中执行此操作。但您也可以在应用程序启动例程中的某个位置调用它。请参阅此页面(“我应该何时记录第一条消息”):http://logging。 apache.org/log4net/release/faq.html
如果您使用基于文件的日志记录,您打算将日志文件存储在哪里? - 目标目录是否存在,并且运行该层的用户帐户是否具有该文件夹的写入权限?对于 Web 应用程序,用户帐户是应用程序池标识,对于 Windows 服务,用户帐户是运行该服务的登录名。对于控制台和 Windows 应用程序,用户帐户可能是启动应用程序的用户。
如果所有其他方法都失败,您可以打开 log4net 内部调试,这可能会有所帮助:http://logging。 apache.org/log4net/release/faq.html(“如何启用 log4net 内部调试”)
Here are a few ideas:
In each tier, do you have a call to
log4net.Config.XmlConfigurator.Configure(...)
? In most cases, people use an assembly attribute to do this in the AssemblyInfo.cs/Program.cs/Global.asax.cs/etc. but you can also just call it somewhere in your application startup routine.See this page ("When should I log my first message"): http://logging.apache.org/log4net/release/faq.html
If you are using file-based logging, where are you trying to store the log files? - does the target directory exist, and does the user account that is running the tier have write permission to that folder? For web apps, the user account is the App Pool identity, and for Windows Services, the user account is the Login that runs the service. For console and windows apps, the user account may be the user that launches the app.
If all else fails you can turn on log4net internal debugging which might help: http://logging.apache.org/log4net/release/faq.html ("How do I enable log4net internal debugging")
我想您已经在 App.config 文件中配置了 log4net 吗?一个常见的错误是忘记在每一层的启动代码中调用
log4net.Config.XmlConfigurator.Configure()
。如果这没有帮助,您需要向我们展示您的 XML 配置。I suppose that you have configured log4net in the
App.config
files? A common mistake is to forget to calllog4net.Config.XmlConfigurator.Configure()
in the startup code of each tier. If that doesn't help, you need to show us your XML configuration.