c# - Setup Nlog unc path by project configuration file -
say defined nlog target as:
<variable name="day" value="${date:format=dddd}"/> <targets> <target name="file" xsi:type="file" layout="${verbose}" filename="${basedir}/${day}.log" /> </targets>
however want place file location @ app config file or other xml file. don't know how set unc path in c# code programmatically rather in nlog configuration file.
edit:
say application distributed in 100 clients in different location in us. each client prefer own log file location. application has own app.config or respective xml file store location. seems no way hard code locations in nlog configuration file.
so needed similar connection strings , db targets (this original question , self answer, may add additional help). taking solution little modifications can try
notes:
1. has not been tested should close.
2. using castle windsor why have factory class setup, dont need that, foreach
public class ownnlogfactory : nlogfactory { public ownnlogfactory(string filepath) { foreach (var dbtarget in logmanager.configuration.alltargets.oftype<filetarget>().select(atarget => atarget)) { dbtarget.filename = filepath; } } }
hope helps, realise asked little while ago stumbled on looking else
Comments
Post a Comment