Quantcast
Channel: Microsoft Online: SharePoint Online forum
Viewing all articles
Browse latest Browse all 10096

Access logs in SharePoint Online

$
0
0

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




Viewing all articles
Browse latest Browse all 10096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>