Windows 服务中 log4net 控制台附加程序的输出会发生什么情况?
我有一个一直在从事的控制台项目。我添加了 log4net 来处理我的所有日志记录。在某些地方我使用了控制台附加器。当我将此应用程序转换为 Windows 服务时,我应该删除控制台附加程序还是该输出会发生什么?它会迷路吗?
如果可能的话,我想保留它,因为如果我直接从命令提示符运行它,我希望看到控制台输出以帮助调试。
I have a console project that I have been working on. I added log4net to handle all my logging. In some places I have made use of the console appender. When I turn this application into a Windows Service should I just remove the console appender or what happens to that output? Does it just get lost?
I would like to keep it if all possible because if I run it straight from the command prompt I would like to see the console output to help debug things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为默认行为,控制台在 Windows 服务、Web 服务、Windows 窗体中不可用。输出将被简单地忽略。
As a default behaviour, the console isn't available in windows services, web services, windows forms. The outpu will simply be dismissed.
正如@Seb 提到的,控制台的输出将消失。为了两全其美(控制台和例如保存到文件),您可以轻松设置两个附加程序,一个控制台,一个 RollingFileAppender。
保留控制台附加程序不会增加显着的开销,除非您确实进行大量日志记录。
As @Seb mentions, output to the console will go into the void. To have the best of both worlds (console AND e.g. saving to a file) you can easily set up two appenders, one console and say, one RollingFileAppender.
Keeping the console appender does not add significant overhead unless you are really doing high-volume logging.