Customising NLog's Logger class

2 messages Options
Embed this post
Permalink
Jonathan Parker

Customising NLog's Logger class

Reply Threaded More More options
Print post
Permalink
Hi,

I'm looking at customising NLog.

Basically I need to be able to pass in a predefined error code with the error message.
The logger should then look up the severity in a file and determine from that what should be called in NLog (Info, Error, Fatal etc).
Our clients will then be able to look at the file to find the description that matches the error code.

I've found it difficult so far to extend Logger via inheritance (no public constructor on Logger).

Is composition the general way?

Any help will be greatly appreciated.

Thanks,

Jonathan.

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Jaroslaw Kowalski

Re: Customising NLog's Logger class

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
The constructor on Logger is protected which is perfectly fine for inheritance. Your derived class just has to have a public constructor.
There's actually an example in:
 
 
It demonstrates how to extend a logger. Note that in order to create loggers of your particular type, you need to call special overloads of LogManager.Get*Logger().
Alternatively you can use generic LogFactory<YourLoggerType> - see the source code in LogFactory.cs
 
Jarek
 
----- Original Message -----
Sent: Thursday, January 08, 2009 11:02 PM
Subject: [Nlog-list] Customising NLog's Logger class

Hi,

I'm looking at customising NLog.

Basically I need to be able to pass in a predefined error code with the error message.
The logger should then look up the severity in a file and determine from that what should be called in NLog (Info, Error, Fatal etc).
Our clients will then be able to look at the file to find the description that matches the error code.

I've found it difficult so far to extend Logger via inheritance (no public constructor on Logger).

Is composition the general way?

Any help will be greatly appreciated.

Thanks,

Jonathan.


------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB


_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list