Wednesday, 15 September 2010

c# - WPF with log4net - save log in userappdata -



c# - WPF with log4net - save log in userappdata -

i have dll project in solution responsible logging events in other projects. right i'm facing problem on save log file. save in user app info (c:\users\\appdata\local\.....)

how can access location in log4net.config file?

i have in dll project:

static log() { log4net.globalcontext.properties["logfilename"] = @"d:\filerelease2"; //log file path #if debug log4net.globalcontext.properties["logfilename"] = @"d:\filedebug2"; //log file path #endif fileinfo configfileinfo = new fileinfo("log4net.config"); log4net.config.xmlconfigurator.configureandwatch(configfileinfo); log = logmanager.getlogger(typeof(log)); }

thanks in advance.

regards,

===========edit 2==========

i've managed set log4net.config this:

<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>

the problem i'm facing in ide (vs2013 ultimate) folder created. when install application (using visual studio project installer) folder/file not created.

if start application admin privileges creates folder/file...

any ideas why?

try using

log4net.globalcontext.properties["logfilename"] = path.combine(environment.getfolderpath(environment.specialfolder.applicationdata), "filerelease2");

c# wpf log4net log4net-configuration

No comments:

Post a Comment