I am trying to use the memory target and therefore need to retrieve the target via LogManager.Configuration.FindTargetByName() first.
The problem is that LogManager.Configuration is always null, so it throws an exception. Is there an additional step to initialize the global configuration object?
My configuration is provided via NLog.config file where two targets are defined (file and memory) and has a couple of rules.
The project uses Windows CE 5.0, .NET CF 2.0 and VS2005.
Thanks for any advice.
Sorry I do have an answer but I have the same problem and can provide some more info. I too would like to hear answers to this.
What I've found is that if I have logging configured in a XML file then early in the app load the configuration is null. If I instantiate a new configuration it seems to stop the logging configured in the XML file. Well at least sometimes, I think it depends on where (how) the app is running.
I also have a memory target that is configured much later in the app load. It always has a non-null configuration.
Let me know if you find anything out. Replies on this forum are a bit hard to come by.
I have checked this property (LogManager.Configuration) in a regular console-based desktop application and it's not NULL, but in the .NET CF application this property is always NULL.
Appears that NLog for .NET CF lacks proper initialization somewhere or am I missing something?
Any ideas why it is so would be greatly appreciated.
In my VS2005 project the Build Action for NLog.config file was not set to Content, hence the file was not being deployed to the target device and that's why the configuration was missing.