Problem with Database as Target

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with Database as Target

ArunRaj.C
I have the following target in my App.Config, but i keep on getting this error "An error occurred creating the configuration section handler for nlog: Target database not found.", and its also not logging anything into the database,

Please help me in configuring the target to Database type

<target name="dbLog" xsi:type="Database"   keepConnection="false" useTransactions="true" dbProvider="mssql"
        connectionString="Server=PROXIMA;Database=Import_DB;Trusted_Connection=True;" commandText="insert into LogTable(ex_TimeStamp, ex_Level, ex_Logger, ex_Message) VALUES (?,?,?,?)"> 
      <parameter name="ex_TimeStamp" layout="${date}" />
       <parameter name="ex_Level" layout="${level}" />
       <parameter name="ex_Logger" layout="${logger}" />
       <parameter name="ex_Message" layout="${message}" />
</target>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Database as Target

Jarek Kowalski
Administrator
You're probably referencing your target incorrectly in the <rules> section. You should reference it by name (dbLog) not the type name (Database):

<rules>
   <logger name="*" writeTo="dbLog" />
</rules>

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|

Re: Problem with Database as Target

ArunRaj.C
Thanks Jarek, It worked