I am having trouble with logging from different classes into separate files. I have DLL, which uses NLog, and application, which uses also NLog, but also the DLL. So when the application starts, it logs events into the right file, but when the application starts the DLL, the logging events from the application are logged into the file specified in the DLL NLog settings. Weird, right?
This is how I log the events from the application:
private static NLog.Logger logger;
public static void InitLogger()
// set NLog
logger = LogManager.GetLogger("DeviceManager");
LoggingConfiguration config = new LoggingConfiguration();
FileTarget fileTarget = new FileTarget();
NLog is doing exactly what you are telling it to do. When your app runs and you log 'correctly' it uses that configuration. When your app then calls the DLL and it runs its InitLogger - all you're really doing is re-configuring the core NLog configuration.
An application can not have multiple NLog configurations.