views:

908

answers:

2

In my current project I'm using two libraries where one is using log4net and the other NLog for its logging. I'm personally prefer NLog so it is used in my application as well.

I'm not knowing much about log4net so I'm asking what would be the best way to programmatically forward all the messages from log4net to NLog.

There is a post about a log4net forwarder at the NLog forum but it looks like no one had done this before.

+4  A: 

create a custom log4net Appender that logs the messages to a nlog logger. this may be at least the solution if you just want to pass the log information to nlog instead of replacing all occurences of log4net logging with nlog.

look here, here and here

Joachim Kerschbaumer
Also check out this post: https://forum.hibernate.org/viewtopic.php?p=2375611
UpTheCreek
+1  A: 

Basically you'll need a log4net appender (log4net.Appender.IAppender) which would delegate all DoAppend calls to NLogs' Logger or Target.

Anton Gogolev