Вопрос

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:

Это было полезно?

Решение

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.

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top