Friday 15 March 2013

c# - WPF starts from batch file doesn't create folder in APPDATA -



c# - WPF starts from batch file doesn't create folder in APPDATA -

i'm facing unusual problem , hope of can help me.

i have made wpf application launched lync 2013 custom menu command. if understand well, launches batch file , execute application.

the application has log4net log errors in application, , if launch application isolated (without beingness lync), folder created in place in log4net.config (programdata or roaming folder).

when launch lync application, folders not created.

i can simulate if create batch file , in phone call application....if folders not created.

does understand behaviour?

thanks

===edit===

my log4net.config

<appender name="logfileappender" type="log4net.appender.rollingfileappender"> <filter type="log4net.filter.levelrangefilter"> <levelmin value="debug" /> <levelmax value="off" /> </filter> <param name="appendtofile" value="true"/> <file value="${appdata}\appname\logs\log" /> <staticlogfilename value="false"/> <appendtofile value="true" /> <rollingstyle value="date" /> <datepattern value=" yyyy-mm-dd&quot;.txt&quot;"/> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%date [%thread] %-5level %logger: %message%newline"/> </layout> </appender>

this solved issue:

replace this:

fileinfo configfileinfo = new fileinfo("log4net.config"); log4net.config.xmlconfigurator.configureandwatch(configfileinfo); log = logmanager.getlogger(typeof(log));

by this:

var log4netconfigdirectory = appdomain.currentdomain.relativesearchpath ?? appdomain.currentdomain.basedirectory; var log4netconfigfilepath = path.combine(log4netconfigdirectory, "log4net.config"); log4net.config.xmlconfigurator.configureandwatch(new fileinfo(log4netconfigfilepath)); log = logmanager.getlogger(logclass);

i think might related bat file opens cmd prompt , log4net.config not in folder command prompt opened default.

c# batch-file log4net

No comments:

Post a Comment