Does anyone have experience with using NLog in SharePoint 2010? With NLog 1.0 I have had what seems to be only intermittent success with logging. I was using the supported environment variable to point NLog to my configuration file. Even then it would seem that results were not as I expected. I am mostly trying to log things happening within my web parts but also have a need to log from within notification handlers and various other event receivers. Certainly the ULS would log for me but I don't find it to be as extensible as I am looking for and would very much like to settle on a single logging framework to be used across different kinds of applications.

I have now moved over to NLog 2.0 and still have no success. I want to at least find some hope that NLog is in fact working for some out there and perhaps there is something I am just missing here.


I used to have your same mentality, wanting all my logging frameworks to be the same. Then i found out how much of a pain it was to get log4net working in SharePoint. Sharepoint has way too many components to get logging working easily and consistently. nlog looks like log4net, where it loads it config from a file or from code. Well if using the config file approach, its a pain, because you have to add your config to each web application ACROSS each server. Then if you want it in the timer service, you need to add it there too. You could use scripts or solutions to push that out, but its a lot of work. And then the same for a code base approach, you would need to deploy your logging code and then make sure it is loading at the right time, and it is really hard to bind into the sharepoint application init pipeline, unless you like httpmodules or putting your sharepoint install in an unsupported state. And anyway, a custom framework will never completely replace the ULS logs, so you may as well use the ULS, as you will be poking around in there when things go belly up.

SharePoint 2010 has a lot better logging framework than 2007 mind you. This page/s helped me a lot while i was learning about it.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.