none
Access logs in SharePoint Online

    Question

  • Hello everyone,

    I'm getting an unexpected error while saving a site as a template and would like to know more information about the error through the correlation ID. For this you should be able to access the logs. I saw a post that through CSOM is supposed to be done, this is the code:

    using (var tenantContext = new ClientContext("https://domain-admin.sharepoint.com"))
                {
                    //Authenticate with a Tenant Administrator
                    var passWord = new SecureString();
                    foreach (char c in "Password".ToCharArray()) passWord.AppendChar(c);
                    tenantContext.Credentials = new SharePointOnlineCredentials("account@domain.onmicrosoft.com", passWord);

                    var tenant = new Tenant(tenantContext);
                    var tenantLog = new TenantLog(tenantContext);
                    var dateTimeUTCNow = DateTime.UtcNow;

                    var logEntries = tenantLog.GetEntries(dateTimeUTCNow.AddDays(-5), dateTimeUTCNow, 50);
                    tenantContext.Load(logEntries);
                    tenantContext.ExecuteQuery();
                    foreach (TenantLogEntry logEntry in logEntries)
                    {
                        Console.WriteLine(string.Format("Timestamp:{0} | Message:{1} | CorrelationId:{2} | Source:{3} | User:{4} | CategoryId:{5}",
                            logEntry.TimestampUtc, logEntry.Message, logEntry.CorrelationId, logEntry.Source, logEntry.User, logEntry.CategoryId));
                    }
                }

    I have done the console application and when I run I do not get any errors but I do not get information from the logs. I do not know if I might be missing a previous configuration step. For example, with a similar code I get all the site collections I have in my tenant but with the logs it is impossible.

    Any ideas?

    Thank you very much in advance



    • Edited by Javier_OC Monday, November 14, 2016 9:10 PM
    Monday, November 14, 2016 9:10 PM

All replies

  • Hi Javier_OC,

    As we consider that the correlation id includes the customer privacy information, this part will be only visible to the Support from the server side. Therefore, if you receive error messages with the Correlation ID, I suggest you contact us or the other Office 365 support channels (the service request) to get the reason as soon as possible.

    Please provide the correlation ID and the date when the error occurred. We will help you capture the error activity logs from the server side.

    Best Regards,

    Linda Zhang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Tuesday, November 15, 2016 10:26 AM