vb.net - log4net not working on other machines -
i created web service project uses log4net log event viewer , optionally .log file. works great on machine, when try deploy on machine won't log text file or event viewer. fact it's not writing text file makes me think it's not able find log4net.dll or effect?
i'm receiving error message when hits noted line below in global.asax:
log4net:error xmlconfigurator: failed find configuration section 'log4net' in application's .config file. check .config file , elements. configuration section should like:
section name="log4net" type="log4net.config.log4netconfigurationsectionhandler,log4net" /
i'm stumped, have no idea why isn't working, help!
ran exe compiled following code adds source eventlog in windows, said, works fine on machine:
option explicit on option strict on imports system imports system.diagnostics imports system.threading module module1 sub main() if not eventlog.sourceexists("lendingservice") eventlog.createeventsource("lendingservice", "application") console.writeline("creating event source: lendingservice") else console.writeline("lendingservice events defined system.") end if end sub
end module
web.config:
<?xml version="1.0"?> <configuration> <appsettings> <add key="aceconfigfilefullpath" value="c:\somepath\bin\acefile.xml" /> <add key="ilconfigfilefullpath" value="c:\somepath\bin\il.xml"/> <add key="log4net.config" value="log4net.config"/> <add key="log4net.config.watch" value="true"/> </appsettings> <connectionstrings/> <system.web> <!-- visual basic options: set strict="true" disallow data type conversions data loss can occur. set explicit="true" force declaration of variables. --> <compilation debug="true" strict="false" explicit="true" targetframework="4.0"/> <!-- <authentication> section enables configuration of security authentication mode used asp.net identify incoming user. --> <authentication mode="windows"/> <!-- <customerrors> section enables configuration of if/when unhandled error occurs during execution of request. specifically, enables developers configure html error pages displayed in place of error stack trace. <customerrors mode="remoteonly" defaultredirect="genericerrorpage.htm"> <error statuscode="403" redirect="noaccess.htm" /> <error statuscode="404" redirect="filenotfound.htm" /> </customerrors> --> <pages controlrenderingcompatibilityversion="3.5" clientidmode="autoid"> <namespaces> <clear/> <add namespace="system"/> <add namespace="system.collections"/> <add namespace="system.collections.generic"/> <add namespace="system.collections.specialized"/> <add namespace="system.configuration"/> <add namespace="system.text"/> <add namespace="system.text.regularexpressions"/> <add namespace="system.linq"/> <add namespace="system.xml.linq"/> <add namespace="system.web"/> <add namespace="system.web.caching"/> <add namespace="system.web.sessionstate"/> <add namespace="system.web.security"/> <add namespace="system.web.profile"/> <add namespace="system.web.ui"/> <add namespace="system.web.ui.webcontrols"/> <add namespace="system.web.ui.webcontrols.webparts"/> <add namespace="system.web.ui.htmlcontrols"/> </namespaces> </pages> <identity impersonate="true" /> </system.web> </configuration>
log4net.config: </configsections>--> yes still works on mine commented out.
<appender name="eventlogappender" type="log4net.appender.eventlogappender"> <param name="applicationname" value="lending service" /> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%date [%thread] %-5level %logger [%property{ndc}] - %message %newline %exception" /> </layout> <filter type="log4net.filter.levelrangefilter"> <levelmin value="info"/> <levelmax value="fatal"/> </filter> </appender> <appender name="rollingfileappender" type="log4net.appender.rollingfileappender"> <threshold value="fatal"/> <file value="weblog.log"/> <appendtofile value="true"/> <rollingstyle value="size"/> <maxsizerollbackups value="5"/> <maximumfilesize value="10mb"/> <staticlogfilename value="true"/> <layout type="log4net.layout.patternlayout"> <conversionpattern value="%date [%thread] %level %logger - %message%newline%exception"/> </layout> </appender> <root> </root> <logger name="lendingservice.global_asax"> <appender-ref ref="rollingfileappender"/> <appender-ref ref="eventlogappender" /> </logger> <logger name="lendingservice.lendingservice"> <appender-ref ref="rollingfileappender"/> <appender-ref ref="eventlogappender" /> </logger> </log4net> <startup> <supportedruntime version="v4.0" sku=".netframework,version=v4.0"/> </startup> </configuration>
assemblyinfo.vb:
imports system imports system.reflection imports system.runtime.interopservices <assembly: log4net.config.xmlconfigurator(configfile:="log4net.config", watch:=true)>
global.asax:
imports system.web.sessionstate imports intellilenderbuclasses public class global_asax inherits system.web.httpapplication 'public objapplicant new intellilenderbuclasses.applicantbu private shared readonly log log4net.ilog = log4net.logmanager.getlogger(system.reflection.methodbase.getcurrentmethod().declaringtype) sub application_start(byval sender object, byval e eventargs) ' fires when application started 'ace dim sacepath string sacepath = system.configuration.configurationmanager.appsettings("aceconfigfilefullpath") aceclientnet.baseconfig.initializebu(sacepath) 'il dim silpath string silpath = system.configuration.configurationmanager.appsettings("ilconfigfilefullpath") intellilenderbuclasses.bubaseconfig.initializebu(silpath) 'logging log4net.config.xmlconfigurator.configure() 'error message happening here log.info("lendingservice application started") end sub sub session_start(byval sender object, byval e eventargs) ' fires when session started end sub sub application_beginrequest(byval sender object, byval e eventargs) ' fires @ beginning of each request end sub sub application_authenticaterequest(byval sender object, byval e eventargs) ' fires upon attempting authenticate use end sub sub application_error(byval sender object, byval e eventargs) ' fires when error occurs dim sendstring string = sender.tostring log.error("lendingservice application error: " & server.getlasterror.message) end sub sub session_end(byval sender object, byval e eventargs) ' fires when session ends end sub sub application_end(byval sender object, byval e eventargs) ' fires when application ends log.info("lendingservice application ending") end sub end class
you looking configuration in app.config file. change can use:
// configure log4net using .log4net file [assembly: log4net.config.xmlconfigurator(configfileextension="log4net",watch=true)] // cause log4net configuration file // called testapp.exe.log4net in application base // directory (i.e. directory containing testapp.exe) // config file watched changes.
or
log4net.config.xmlconfigurator(configfileextension="log4net",watch=true)]
as reference:
// configure log4net using .config file [assembly: log4net.config.xmlconfigurator(watch=true)] // cause log4net configuration file // called testapp.exe.config in application base // directory (i.e. directory containing testapp.exe) // config file watched changes.
Comments
Post a Comment