BufferingWrapper over compound target doesn't work.

4 messages Options
Embed this post
Permalink
Normalex

BufferingWrapper over compound target doesn't work.

Reply Threaded More More options
Print post
Permalink
I'm not sure was it intended to work in the initial design but doesn't in the following config file.
Buffering only works when declared over each target. But if network share becomes unreachable then all the buffer data will be lost and FallbackTarget switches to the next one.


<?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" internalLogFile="C:\Temp\nlog.log" throwExceptions="true" internalLogLevel="Trace">

        <variable name="FCUCopyResultLogPath" value="${gdc:FCUCopyResultLogPath}"/>
        <variable name ="FCUCopyResultLogName" value="${gdc:FCUCopyResultLogName}"/>
        <variable name="SizeThreshold" value="524288"/>
        <variable name ="MaxArchiveFiles" value="1000"/>

        <targets async="false">
                <wrapper-target xsi:type="BufferingWrapper" bufferSize="1000" name="testBuffer">
                        <compound-target xsi:type="FallbackGroup" name="FallbackGroup" returnToFirstOnSuccess="false">
                                <target name="primaryFile"
                                                xsi:type="File"
                                                fileName="${FCUCopyResultLogPath}"
                                                networkWrites="true"
                                                concurrentWrites="false"
                                                encoding="utf-16"
                                                archiveAboveSize="${SizeThreshold}"
                                                deleteOldFileOnStartup="true"
                                                maxArchiveFiles="${MaxArchiveFiles}">

                                        <layout xsi:type="CSVLayout" delimiter="Tab">
                                                <column name="time" layout="${longdate}" />
                                                <column name="message" layout="${message}" />
                                                <column name="logger" layout="${logger}"/>
                                                <column name="level" layout="${level}"/>
                                        </layout>
                                </target>
                                <target name="secureFile"
                                                xsi:type="File"
                                                fileName="${specialfolder:folder=DesktopDirectory:upperCase=true}\${FCUCopyResultLogName}"
                                                        networkWrites="false"
                                                        concurrentWrites="false"
                                                        encoding="utf-16"
                                                        archiveAboveSize="${SizeThreshold}"
                                                        deleteOldFileOnStartup="true"
                                                        maxArchiveFiles="${MaxArchiveFiles}">

                                        <layout xsi:type="CSVLayout" delimiter="Tab">
                                                <column name="time" layout="${longdate}" />
                                                <column name="message" layout="${message}" />
                                                <column name="logger" layout="${logger}"/>
                                                <column name="level" layout="${level}"/>
                                        </layout>
                                </target>
                        </compound-target>
                </wrapper-target>
        </targets>

        <rules>
                <logger name="*" minlevel="Debug" writeTo="testBuffer" />
        </rules>
</nlog>
Jaroslaw Kowalski

Re: BufferingWrapper over compound target doesn't work.

Reply Threaded More More options
Print post
Permalink
Compound targets don't support buffering - they pass events to underlying targets one-by-one so your scenario should not lose buffer data. Can you send me samples of both log files which demonstrate data loss?
Normalex

Re: BufferingWrapper over compound target doesn't work.

Reply Threaded More More options
Print post
Permalink
The buffered data will be lost if you wrap separately each target in compound target in the BufferingWrapper.  I did so to achieve reasonable performance when logging goes to network shares. So if the network share drops then it can be switched to another target, but the previous buffered data will be lost. Otherwise, as you stated, the data wouldn't be lost because compound targets  do not support buffering.

Will the buffering be supported in compound targets in future releases?
Jaroslaw Kowalski

Re: BufferingWrapper over compound target doesn't work.

Reply Threaded More More options
Print post
Permalink
Thanks for your explanation.
 
Supporting buffering for compound targets (in particular targets that deal with faulure - such as retrying, etc.) is tricky, because the outer compound does not know which items from the buffer were processed (if any). I'll see if there's anything that can be done to address that.
 
Jarek

On Fri, Aug 7, 2009 at 3:27 PM, Normalex (via Nabble) <[hidden email]> wrote:
The buffered data will be lost if you wrap separately each target in compound target in the BufferingWrapper.  I did so to achieve reasonable performance when logging goes to network shares. So if the network share drops then it can be switched to another target, but the previous buffered data will be lost. Otherwise, as you stated, the data wouldn't be lost because compound targets  do not support buffering.

Will the buffering be supported in compound targets in future releases?