Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

http://dbremes.wordpress.com/2010/09/02/using-sharepoint-2010s-logging-infrastructure-part-1/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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