app config - log file is not created using log4net -


i have downloaded log4net.dll , added service reference. 1 of project have created has app.config have made following configurations

<?xml version="1.0"?> <configuration> <configsections>     <section name="log4net"type="log4net.config.log4netconfigurationsectionhandler,log4net"/> </configsections> <log4net>            <appender name="rollinglogfileappender" type="log4net.appender.rollingfileappender" >         <param name="file" value="c:\\users\\<myid>\\desktop\\error.log"/>         <appendtofile value="true" />         <rollingstyle value="size" />         <maxsizerollbackups value="10" />         <maximumfilesize value="10mb" />         <staticlogfilename value="true" />     </appender>     <root>         <level value="all" />         <appender-ref ref="rollingfileappender" />     </root> </log4net> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.0"/> </startup> <system.servicemodel>     <bindings />     <client /> </system.servicemodel> </configuration> 

i have entry form , created , declared

private static readonly log4net.ilog logger = log4net.logmanager.getlogger   (system.reflection.methodbase.getcurrentmethod().declaringtype); 

this inside partial class , the logging have used here

 private void entry_load(object sender, eventargs e)     {         log4net.config.xmlconfigurator.configure();         logger.debug("logged");                 } 

and have added

[assembly: log4net.config.xmlconfigurator(configfile = "app.config", watch = true)] 

in assemblyinfo.cs class

and added in main.cs class

static void main(string[] args) {             log4net.config.xmlconfigurator.configure();             logger.debug("app started");     } 

the log file not created , when debug runs through these codes properly. using log4net.dll version 1.2.13 desktop applications using .net 4.0 c#. how can achieve this?

@peer right, need pick 1 method of configuring log4net , use correctly.

i think immediate problem though you've specified app.config config file in assembly attribute, must specify your_app_name.exe.config file's name after project built (the name differ depending on actual name of app, in build output directory see called)

alternatively, "if neither of configfile or configfileextension properties specified, application configuration file (e.g. testapp.exe.config) used log4net configuration file." omit configfile attribute altogether:

[assembly: log4net.config.xmlconfigurator(watch=true)] 

(the documentation states is possible watch app.config file, long pass fileinfo configureandwatch or use assembly attribute.)

if have more problems, though, set log4net debug mode declaration <log4net debug=true> in config , check trace output @ runtime reported configuration issues.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -