What happens to the output to a log4net console appender in a Windows service?
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.
As a default behaviour, the console isn't available in windows services, web services, windows forms. The outpu will simply be dismissed.
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.
精彩评论