2

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>

1 Answer 1

2

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).

2
  • 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
    Commented May 31, 2011 at 17:00
  • I found this blog post which I believe is the source of the issue. tjo.me/kLemAG
    – ChiliYago
    Commented May 31, 2011 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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