Config file loading by command

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Config file loading by command

jkfriends
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
Reply | Threaded
Open this post in threaded view
|

Re: Config file loading by command

mike s
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.
Reply | Threaded
Open this post in threaded view
|

Re: Config file loading by command

jkfriends
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
Reply | Threaded
Open this post in threaded view
|

Re: Config file loading by command

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

I just use this, as you mentioned in your post, but still not getting logs.
Configfiile is the name of NLog or web.Log

I use NLog.config as an argument but still not working.