Automatic wrapping of targets with AsyncWrapper

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

Automatic wrapping of targets with AsyncWrapper

Jarek Kowalski
Administrator
I received some post-v0.95 feedback saying that implementing async targets
should be somewhat easier in the config file.

Since async logging is something you might want to do quite often, I came up
with the following syntax idea:

<nlog>
    <targets async="true">
        ...
    </targets>

    <rules>
        ...
    </rules>
</nlog>

Note that NLog permits multiple <targets/> and <rules /> sections, so if you
prefer just some of your targets to be async by default, you can write it
like this:

<nlog>
    <targets async="true">
        ...
    </targets>

    <targets async="false">
        ...
    </targets>

    <rules>
        ...
    </rules>
</nlog>

Under the hood, setting async="true" would wrap each target defined within
the <targets /> with an instance AsyncWrapper target. The AsyncWrapper would
get it's name from the wrapped target (which would be renamed to
originalName + "_sync"). This way all the rules would get routed to the
AsyncWrapper instead of the wrapped one.

I also have another idea to let you fully specify the wrapper that you want
to wrap others with. How about:

<default-wrapper>
    <wrapper type="AsyncWrapper" />
</default-wrapper>

or even;

<default-wrapper>
    <wrapper type="AsyncWrapper">
        <wrapper type="RetryingWrapper">
            <wrapper type="AutoFlushWrapper" />
        </wrapper>
    </wrapper>
</default-wrapper>

This would make all targets be wrapped with a chain of 3 wrappers, namely:
async, retrying and auto-flushing ones.

What do you think about the idea? Which version would you prefer? What if
both got implemented? Where do you think <default-wrappers> belongs? At the
<targets> level or at the <nlog> level? Isn't the whole idea too difficult
to understand?

(I personally prefer simple things and I think that implementing just
async="true" would be sufficient for the 80% case and the other concept
<default-wrapper> would just add abstraction that I'm not convinced is
necessary)

Jarek



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog
Reply | Threaded
Open this post in threaded view
|

RE: Automatic wrapping of targets with AsyncWrapper

Francis1
Hi Jaroslaw,

Great idea!

I vote for:
<nlog>
    <targets async="true">

The <default-wrapper> is also very simple to understand, but I personally
wouldn't use it for now.

Thanks,

Francis



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list