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

The following code results in a security exception in a custom web part I am developing. I want to log issues to the ULS but the web part crashes on this line. I have looked hi and low for the reason for this with no luck. Thanks in advance.

SPDiagnosticsService.Local.WriteTrace(
    0,
    new SPDiagnosticsCategory("SJHS", TraceSeverity.None, EventSeverity.Information),
    TraceSeverity.Monitorable,
    "My Web Part Error",
    "My Error Msg");

Error:

Log Name:      Application
Source:        Microsoft-SharePoint Products-SharePoint Foundation
Date:          5/28/2011 8:39:40 AM
Event ID:      6615
Task Category: Runtime
Level:         Error
Keywords:      
User:          domain\farmsetup
Computer:      server.domain.org
Description:
The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-SharePoint Products-SharePoint Foundation" Guid="{6FB7E0CD-52E7-47DD-997A-241563931FC2}" />
    <EventID>6615</EventID>
    <Version>14</Version>
    <Level>2</Level>
    <Task>10</Task>
    <Opcode>0</Opcode>
    <Keywords>0x4000000000000000</Keywords>
    <TimeCreated SystemTime="2011-05-28T13:39:40.482933400Z" />
    <EventRecordID>26192</EventRecordID>
    <Correlation ActivityID="{06864865-B954-48B9-910F-E048D8618FB7}" />
    <Execution ProcessID="5644" ThreadID="2040" />
    <Channel>Application</Channel>
    <Computer>server.mydomain.org</Computer>
    <Security UserID="S-1-5-21-798254582-200106796-1537874043-188370" />
  </System>
  <EventData>
    <Data Name="string0">The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.</Data>
  </EventData>
</Event>
share|improve this question

1 Answer 1

You're trying to log something using a new trace category, right. I think it might have to do with that your account myDomain\farmsetup does not have permissions to create that category in the Event log (note; not the trace log). Temporarily set your account to local admin and try to generate the error, then remove the local admin rights and try again, so the category gets created. (remember to restart necessary services, log in/out between permisson changes).

share|improve this answer
    
Hi Wictor, Thanks for the reply. This account is local admin on all servers in my farm. I am now attempting to place my code in a RunWithElevatedPrevileges block but unfortunately now receive this error: System.Security.SecurityException was unhandled by user code Message=The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security. –  ChiliYago May 31 '11 at 17:00
    
I found this blog post which I believe is the source of the issue. tjo.me/kLemAG –  ChiliYago May 31 '11 at 20:50

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.