Nlog keeps calling the NLog.Targets.DatabaseTarget.Write(AsyncLogEventInfo[] logEvents) method.

141 views
Skip to first unread message

smartgoblin

unread,
Dec 3, 2012, 6:24:58 AM12/3/12
to nlog-...@googlegroups.com
Dear users, I need you help with the following:

I'v implemented NLog on a webservice hosted by IIS 7.5.

When Nlog is triggerd for the first time is succesfully generates its configuration and starts logging. Where it fails is that while it has started it creates a high cpu usage. From the extra logging I added in the source code of Nlog I found out that event when there are no LogEvnents the DatabaseTarget method keeps being called withtout reason as there is nothing to do.

Kim Christensen

unread,
Dec 4, 2012, 1:10:05 PM12/4/12
to nlog-...@googlegroups.com
Could you post the config file?

Charly Peeters

unread,
Dec 5, 2012, 3:15:25 AM12/5/12
to nlog-...@googlegroups.com
Dear Christensen,

Here is my config file:

<?xml version="1.0" encoding="utf-8" ?>
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="C:\inetpub\wwwroot\NlogTest\file.txt">
    <targets>
        <!-- Configuration to log in a SQL DataBase Table -->      
        <!-- Synchro -->
        <target name="databaseAsyncSynchro" xsi:type="AsyncWrapper">
            <target name="databaseSynchro" xsi:type="Database" keepConnection="false">
                <dbProvider>mssql</dbProvider>
                <dbHost>***</dbHost>
                <dbDatabase>***</dbDatabase>
                <dbUserName>***</dbUserName>
                <dbPassword>***</dbPassword>
                <commandText>
                    INSERT INTO [Synchro]
                    ([ClientID], [UserID], [Host], [IP], [CreatedDate], [SynchroStepID], [TransactionID], [Content], [Exception])
                    VALUES (@clientid,@userid ,@host ,@ip ,@createddate ,@synchrostepid ,@transactionid ,@content ,@exception)
                </commandText>
                <parameter name="@createddate"      layout="${date:format=yyyy-MM-dd HH\:mm\:ss\:fff}" />
                <parameter name="@host"             layout="${machinename}" />
                <parameter name="@message"          layout="${message}" />
                <parameter name="@clientid"         layout="${event-context:item=ClientID}" />
                <parameter name="@userid"           layout="${event-context:item=UserID}" />
                <parameter name="@synchrostepid"    layout="${event-context:item=SynchroStepID}" />
                <parameter name="@ip"               layout="${asp-request:serverVariable=REMOTE_ADDR}" />
                <parameter name="@transactionid"    layout="${event-context:item=TransactionID}" />
                <parameter name="@content"          layout="${event-context:item=Content}" />
                <parameter name="@exception"        layout="${event-context:item=Exception}" />
            </target>
        </target>
    </targets>
    <rules>
    </rules>
</nlog>

I would also like to note that the configuration key "timetosleepbetweenbatches" is not used in the code, or do not know when it is used but the property in the code is always set to 50ms.

Kind regards,


--
You received this message because you are subscribed to the Google Groups "NLog-Users" group.
To post to this group, send email to nlog-...@googlegroups.com.
To unsubscribe from this group, send email to nlog-users+...@googlegroups.com.
Visit this group at http://groups.google.com/group/nlog-users?hl=en.
 
 

Reply all
Reply to author
Forward
0 new messages