作为服务安装时,使用具有 NServiceBus GenericHost 的生产配置文件和默认 log4net 设置的日志文件在哪里?

发布于 2024-12-11 14:30:40 字数 515 浏览 0 评论 0原文

我有一个非常简单的 NServiceBus.Host.exe 应用程序,它使用默认日志记录和生产配置文件。根据文档,这应该会产生一个附加文件日志,该日志应该出现在与执行文件。但是,当我将应用程序作为服务运行时,日志文件不会出现在与 EXE 相同的文件夹中,到目前为止我根本无法找到它。该服务作为本地系统运行。我是否需要以用户帐户运行它并在 AppData 文件夹中的某个位置查找该文件?是在 c:\windows 下的某个地方吗?它在哪里?有没有办法让它真正记录到与广告中的 EXE 位于同一文件夹中的文件中?

更新: 使用 SysInternals 中的 ProcMon 和 ProcExp,我可以看到没有尝试在我的 EXE 所在的文件夹中创建任何日志文件,在尝试在任何地方创建日志文件时也没有任何文件权限错误,至少不是从 PID服务(如果由于某种原因 log4net 启动另一个进程来完成这项工作,那么我可能会错过它)。

I have a very simple NServiceBus.Host.exe application that is using the default logging and the Production profile. According to the documentation, this should result in an appending file log that should appear in the same folder as the EXE. However, when I run the application as a service, the log file doesn't appear in the same folder as the EXE, and thus far I've been unable to locate it at all. The service is running as Local System. Do I need to run it as a user account and look for the file in the AppData folder somewhere? Is it under c:\windows somewhere? Where is it and is there a way for me to have it actually log to a file in the same folder as the EXE as advertised?

Update:
Using ProcMon and ProcExp from SysInternals, I can see that there is no attempt to create any log file in the folder where my EXE exists, nor are there any file permission errors while trying to create a log file anywhere, at least not from the PID of the service (if for some reason log4net spins up another process to do this work then I might have missed it).

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

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

发布评论

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

评论(1

意中人 2024-12-18 14:30:40

事实证明,该服务实际上并未在生产配置文件中运行。出于某种原因,我认为服务默认在生产配置文件中运行,而在交互模式下运行则默认使用 Lite。并非如此 - 除非您另外指定,否则该服务将使用 Lite 配置文件。我更改了安装服务的命令:
NServiceBus.Host.exe /install /displayName:MyService

NServiceBus.Host.exe /install /displayName:MyService NServiceBus.Production

这解决了问题。

It turns out that the service wasn't actually running in the Production profile. I had for some reason gotten it into my head that services would run in the production profile by default, while running it in interactive mode would use Lite by default. Not so - the service will use the Lite profile unless you specify otherwise. I changed my command to install the service from:
NServiceBus.Host.exe /install /displayName:MyService
to
NServiceBus.Host.exe /install /displayName:MyService NServiceBus.Production

and this fixed the issue.

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