Accessing SharePoint Audit Logs Programmatically (via PnP?)

%3CLINGO-SUB%20id%3D%22lingo-sub-66764%22%20slang%3D%22en-US%22%3EAccessing%20SharePoint%20Audit%20Logs%20Programmatically%20(via%20PnP%3F)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-66764%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20access%20the%20SharePoint%20(Online)%20Site%20Collection%20Audit%20Logs%20programmatically%3F%20%26nbsp%3BSeems%20like%20it's%20available%20in%20CSOM%20using%26nbsp%3B%3CSPAN%3ESPAuditQuery(%3F)%2C%20but%20I'm%20hoping%20there%20is%20a%20way%20using%20PnP%20maybe%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EMany%20thanks%20for%20any%20assistance%20anyone%20can%20provide.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EKind%20regards%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ED.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-66764%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-66958%22%20slang%3D%22en-US%22%3ERe%3A%20Accessing%20SharePoint%20Audit%20Logs%20Programmatically%20(via%20PnP%3F)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-66958%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%26nbsp%3BThanks%20for%20the%20reply.%20%26nbsp%3BI've%20used%20that%20for%20setting%20the%20auditing%20settings%2C%20but%20I%20mean%20I'd%20like%20to%20access%20the%20actual%20logs.%20%26nbsp%3BIdeally%2C%20there%20would%20be%20a%20Power%20BI%20content%20pack%20for%20it.%20%26nbsp%3BHaving%20to%20look%20across%20200%20site%20collections%20for%20the%20logs%20manually%20isn't%20feasible%2C%20so%20I%20wondered%20if%20I%20could%20access%20the%20content%20of%20the%20logs%20programmatically%20to%20upload%20to%20a%20database%20for%20analysis%2Freporting%20etc.%20%26nbsp%3BThanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-66876%22%20slang%3D%22en-US%22%3ERe%3A%20Accessing%20SharePoint%20Audit%20Logs%20Programmatically%20(via%20PnP%3F)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-66876%22%20slang%3D%22en-US%22%3EHave%20you%20seen%20this%3F%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Ftree%2Fmaster%2FSamples%2FCore.Settings.Audit%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Ftree%2Fmaster%2FSamples%2FCore.Settings.Audit%3C%2FA%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fblob%2Fmaster%2FDocumentation%2FSetPnPAuditing.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-PowerShell%2Fblob%2Fmaster%2FDocumentation%2FSetPnPAuditing.md%3C%2FA%3E%3C%2FLINGO-BODY%3E
Contributor

Hi,

 

Is there a way to access the SharePoint (Online) Site Collection Audit Logs programmatically?  Seems like it's available in CSOM using SPAuditQuery(?), but I'm hoping there is a way using PnP maybe?

 

Many thanks for any assistance anyone can provide.

Kind regards,

D.

2 Replies

Hi  Thanks for the reply.  I've used that for setting the auditing settings, but I mean I'd like to access the actual logs.  Ideally, there would be a Power BI content pack for it.  Having to look across 200 site collections for the logs manually isn't feasible, so I wondered if I could access the content of the logs programmatically to upload to a database for analysis/reporting etc.  Thanks again.