[dba-VB] C# - NLog to SQL Server

jwcolby jwcolby at colbyconsulting.com
Sun Jul 25 22:11:52 CDT 2010


Is anyone doing this?  I am using the following as a config:

         <target name="base" xsi:type="Database" keepConnection="true" useTransactions="true"
         dbProvider="sqlserver" connectionString="Data Source=Azul;Initial 
Catalog=_NLogDatabase;Integrated Security=True;">
         <commandText>
           INSERT INTO LogTable(time_stamp, [level], logger, [message]) VALUES 
(@time_stamp, at level, at logger, at message)
         </commandText>
         <parameter name="@time_stamp" layout="${date:format=yyyy\-dd\-MM HH\:mm\:ss}"/>
         <parameter name="@level" layout="${level}"/>
         <parameter name="@logger" layout="${logger}"/>
         <parameter name="@message" layout="${message}"/>

       </target>

I have a server Azul, I am using integrated security, I created a database _NLogDatabase and a table 
NLog with fields of those names.

Data types:
Time_Stamp: DateTime
Level: Varchar(50)
Logger: VarChar(50)
Message: Varchar(max)

So far the logs are going to file but not to the table.

-- 
John W. Colby
www.ColbyConsulting.com



More information about the dba-VB mailing list