Config file loading by command

3 messages Options
Embed this post
Permalink
jkfriends

Config file loading by command

Reply Threaded More More options
Print post
Permalink
Hi,

As I described in the other post, I'm trying to use the NLog system in the WCF application where the client side invokes the service APIs via WCF.  I would like to have the logging only on the service side which means that the Nlog.Config resides only on the service side.  However when I launch the client side, the NLog system would not find the config file in the client side as it is present only on the service side.

If I programmatically write the configuration on the service side, it works like a charm.  However when I put the configuration in Nlog.config in the service DLL location, the NLog system does not read it from the configuration file and the logger is unusable.

Is there a way to read the Nlog config file by command as opposed it to automatically read it?  Actually log4net provides a functiion to read the config fromn a given file however it lacks so many features that Nlog provides.

Could you please share some light on how to achieve this?

Thanks, JK
mike s

Re: Config file loading by command

Reply Threaded More More options
Print post
Permalink
I am having the same issue with NLog and my WCF application on the server side.  I only want to write out certain events from the service side not from the client, but the logmanager can't seem to find my NLog.config file.
jkfriends

Re: Config file loading by command

Reply Threaded More More options
Print post
Permalink
Mike, I solved this issue by actually calling the method to load the configuration file.

    NLog.Config.XmlLoggingConfiguration xlc = new XmlLoggingConfiguration(configFile);
    LogManager.Configuration = xlc;


Where configFile is the location of the configuration file.

You will need to put these lines in the static constructor of your Service Implementation code so that you would read the configuration file only once.

Also I would recommend that you go through the help guide for a couple of days and play with them to familiarize yourself with the features.

Good luck!

JK