Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

logging in a WebPart

  Asked By: Prince    Date: Jan 13    Category: Sharepoint    Views: 865

I'm trying to get log4net running in a C# Web Part that's supposed to
run in SPS.
Has anybody succeeded in doing this?
I'm not 100% sure of the position of the configuration in web.config.
I also keep getting security errors when the Web.Config configuration
is accepted.

Are there alternative logging systems out there that are usable in Web
Parts?

Share: 

 

7 Answers Found

 
Answer #1    Answered By: Rashawn Hopper     Answered On: Jan 13

Any library can be called from a web  Part. There’s nothing special about it. The only issue is what credentials you’re running  under when you make that call. We use Enterprise Libraries logging  block but they’re all the same. Just make sure you do some kind of impersonation because the user probably won’t have access to things like web.config when it tries to read the configuration.

 
Answer #2    Answered By: Horace Coffey     Answered On: Jan 13

Care to shed some light on the impersonation bit? I have never used it
as this is my first SPS project.

 
Answer #3    Answered By: Rigoberto Beard     Answered On: Jan 13
 
Answer #4    Answered By: Alphonso Mckay     Answered On: Jan 13

Subject says that this post is about logging  but the
topic is impersonation.
Can we take care to put relevant subjects :)

 
Answer #5    Answered By: Daron Oneill     Answered On: Jan 13

Take a look at thisw article: http://www.15seconds.com/issue/040511.htm and
msdn.microsoft.com/.../frlr\
fsystemsecurityprincipalwindowsimpersonationcontextclasstopic.asp

 
Answer #6    Answered By: M Juarez     Answered On: Jan 13

I've been told that if you first use RevertToSelf() as described in my
SharePoint Advisor article (referenced here: http://tinyurl.com/8wb78)
followed by a call to impersonate the System.IntPtr.Zero System account
as described on my blog (referenced below), I believe you not only get a
credential-less God-mode security  context, but no part  of the SharePoint
Object Model is precreated based on the HttpContext. So, you can perform
any SharePoint action.

I haven't had a chance to try this out myself but I'd love to hear your
experience.

Admittedly, we've used a secondary AppDomain in our production sites
(custom Web Apps not Web Parts) for over a year now. Since SharePoint
objects (like SPList and SPListItem) are not serializable, we have to
repackage all this data. Plus, we have to keep the God-mode credentials
somewhere. I can't wait to use another approach.

 
Answer #7    Answered By: Marty Mcdowell     Answered On: Jan 13

I’m using the revised example from your blog to call a sharepoint web  service from a custom web service, and it seems to work great. I’m going to try it from an InfoPath form; I’m thinking it won’t work because the infopath form is running  on the client, therefore doesn’t have access to the sharepoint app pool. I’ll post the results…

 
Didn't find what you were looking for? Find more on logging in a WebPart Or get search suggestion and latest updates.




Tagged: