When calling HostConfigurator.RunAsLocalSystem()
or equivalent, the TopShelf library outputs several lines to the console.
How to I prevent TopShelf from outputing these lines?
Whilst William Morrison's answer is correct, for the benefit of people landing here looking to enable logging with TopShelf, here is one of the ways using NLog
Step 1: Install the following via NuGet PackageManager Console> Install-Package TopShelf PackageManager Console> Install-Package TopShelf.NLog
Step 2: In the configuration lambda, tell TopShelf that you intend to use NLog
HostFactory.Run(configurator =>
{
configurator.Service<NotificationEngineService>(svc =>
{
// configure service start, stop etc. here
});
// The below option is add via TopShelf.NLog.dll assembly
configurator.UseNLog();
// Continue configuring
});
The console output is logging information. If you use a logging framework with Topshelf the lines appear in log files instead of the console.
I recommend using a logging framework with Topshelf. You should always be logging in a serious project anyway, and it eliminates the lines from the console. Win/win.