简体   繁体   中英

Log to different files with nlog

I'm trying to log to different files using Nlog. For now i'm logging to two different files, one for application, second for Topshelf and Masstransit. In my app i initializing my logger like this LogManager.GetLogger("MyLogger");

which is configured in Nlog.config.

This is Masstransit and Topshelf logging configured

NLogLogger.Use();
HostLogger.UseLogger(new NLogLogWriterFactory.NLogHostLoggerConfigurator());

How could i configure Topshelf and Masstransit 3 to use different Nlog loggers?

You can pass a LogFactory to MassTransit in the configuration:

Bus.Factory.CreateUsingXxx(x => x.UseNLog(logFactory));

That LogFactory can be created using a separate NLog configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM