Custom target wrapper

3 messages Options
Embed this post
Permalink
Wuzuf

Custom target wrapper

Reply Threaded More More options
Print post
Permalink
Hi,

I would like to have a custom target wrapper that looks like the BufferingWrapper, except that it dumps the logs only on given events (user request, uncaught exception...). I don't know if this is feasible with the provided wrappers.

I was trying to develop my own wrapper when it appeared impossible to me since the Write method of the Target base class is "protected internal", and my class is not in the nlog assembly. I need to call it on the wrapped target... Do you have any solution to fix this?

The solution I found needs updating the "WrapperTargetBase" class. I added a protected Write method that calls WrappedTarget.Write. This way I can have my custom wrapper inherit from WrapperTargetBase and call the WrappedTarget.Write method thru a base.Write call.

What do you think of this? Is there any chance we could have it in a coming release?

Rgds,

Gabriel
Rob Smyth

Re: Custom target wrapper

Reply Threaded More More options
Print post
Permalink
Hi,

I'm having the same problem. Is there a way to write a target wrapper without modifying NLog?

I'm hitting the same problem that the Target.Write method is internal. Would be great if it wasn't.

Rob Smyth
Jaroslaw Kowalski

Re: Custom target wrapper

Reply Threaded More More options
Print post
Permalink
This is clearly a bug. Can you file it on nlog.codeplex.com? There is going to be a 1.1 release soon which will address those kinds of things.

On Tue, Oct 27, 2009 at 12:40 AM, Rob Smyth [via NLog Forum] <[hidden email]> wrote:
Hi,

I'm having the same problem. Is there a way to write a target wrapper without modifying NLog?

I'm hitting the same problem that the Target.Write method is internal. Would be great if it wasn't.

Rob Smyth