1

I've tried to add custom ULS logging to my SP Feature, the feature code runs correctly and I can see the results in my library, but none of the logging appears to occur. I've based this off a few online blogs (listed at the end), have I done something wrong? I'm viewing the ULS log through ULSViewer.

    private void writeLog(string log)
    {
        SPDiagnosticsService.Local.WriteTrace(0,
            new SPDiagnosticsCategory("TCBS Email Handler", TraceSeverity.Medium, EventSeverity.Information),
            TraceSeverity.Medium,
            "TCBS: {0}",
            new object[] { log }
        );
    }

    public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
    {
        writeLog("Beginning metadata extraction.");
        ...
    }

Blogs used as reference:

0

2 Answers 2

0

Run the code using SPSecurity.RunWithElevatedPrivileges(). This way code will get executed using App pool account. If the app pool account is part of the group Performance Log Users, the code will be able to write in the ULS logs.

0

In order to make ULS logging work for a AppPool account that is not Administrator you have to add your AppPool user to "Performance Log Users" group.

And restart the Application Pool that is using this AppPool account.

2
  • That doesn't seem to have any effect, I first tried adding the user that runs OWSTIMER to it, and then I added the Everyone group to it, restarted SharePoint and tried again, my custom logs still aren't appearing in the ULS logs. Is there any other configuration I might need to do in Central Admnistration to allow custom logging?
    – bdx
    Commented Jul 3, 2015 at 4:52
  • Please cross check the central admin configuration from "c-sharpcorner.com/UploadFile/40e97e/…"
    – Hardik
    Commented Jul 3, 2015 at 6:12

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.