1
votes

I am in search of method or ways to log data into multiple tables using NLog. I have more than one log tables with different structures in my case. And, I would like to log two different datas in these two tables.

Please let me know if there is a way to configure NLog to handle two different tables while logging.

1

1 Answers

3
votes

You need two database targets, one for each table.

e.g.

<targets>
  <target name="table1" xsi:type="Database"
         ... />
  <target name="table2" xsi:type="Database"
         ... />
</targets>

<rules>
   <logger name="logger1" minlevel="Info" writeTo="table1" />
   <logger name="logger2" minlevel="Info" writeTo="table2" />
</rules>