c# - NLog exception when writing to a database -


i have nlog 4.2.3 configured write database , text file using following config:

<?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/nlog.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" autoreload="true" internalloglevel="error" internallogfile="c:/tmp/nlog.txt">     <targets>       <target name="database" xsi:type="database" dbprovider="npgsql.npgsqlfactory,npgsql,version=2.0.12.00,culture=neutral,publickeytoken=5d8b90d52f46fda7" connectionstring="server=xxx.xxx.xxx.xxx;port=5432;user id=userid;password=password;database=testdb;">       <commandtext>insert invoice_log (message, level, logger) values (@msg, @level, @logger)</commandtext>        <parameter name="@msg" layout="${message}" />       <parameter name="@level" layout="${level}" />       <parameter name="@logger" layout="${logger}" />     </target>      <target name="log" xsi:type="file" layout="${longdate} | ${logger} | ${level:uppercase=true}: ${message}" filename="${basedir}/logs.txt" keepfileopen="false" encoding="iso-8859-2" />   </targets>    <rules>     <logger name="*" minlevel="trace" writeto="database" />     <logger name="*" minlevel="trace" writeto="log" />   </rules> </nlog> 

i'm trying log simple info message. logs correctly text file, fails database , following error in nlog internal log file:

error error when writing database system.missingmethodexception: no parameterless constructor defined object.    @ system.runtimetypehandle.createinstance(runtimetype type, boolean publiconly, boolean nocheck, boolean& canbecached, runtimemethodhandleinternal& ctor, boolean& bneedsecuritycheck)    @ system.runtimetype.createinstanceslow(boolean publiconly, boolean skipcheckthis, boolean fillcache, stackcrawlmark& stackmark)    @ system.runtimetype.createinstancedefaultctor(boolean publiconly, boolean skipcheckthis, boolean fillcache, stackcrawlmark& stackmark)    @ system.activator.createinstance(type type, boolean nonpublic)    @ system.activator.createinstance(type type)    @ nlog.targets.databasetarget.openconnection(string connectionstring)    @ nlog.targets.databasetarget.ensureconnectionopen(string connectionstring)    @ nlog.targets.databasetarget.writeeventtodatabase(logeventinfo logevent)    @ nlog.targets.databasetarget.write(logeventinfo logevent) 

i have looked @ configs other similar questions (nlog not writing database table, nlog postgresql connection), can't see missing mine?

according nlog docs, dbprovider invariant name factory registered in config file or qualified name of type implements idbconnection. npgsql.npgsqlconnection implements required interface , has parameterless contructor. npgsqlfactory not , not have parameterless constructor (the cause of error).


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -