Audit Logging and Reporting
Complete the full lesson to earn 25 points — 50 with Pro
Work through each section, then tap “Mark as Complete” on the last one.
✦ Skip the page breaks, the wait, and see fewer ads — read each lesson on a single page with Pro
Lesson: Audit Logging and Reporting in Microsoft 365
Introduction: Why Audit Logging Matters
In the modern digital workspace, data is the most valuable asset an organization possesses. As companies migrate their operations to cloud-based environments like Microsoft 365, the perimeter of security has shifted from the physical office to the user identity and the data itself. Audit logging is the practice of tracking and recording every significant event, action, and access attempt within your Microsoft 365 tenant. It serves as your digital "black box," providing a chronological account of who did what, when they did it, and from where the action originated.
Without a comprehensive auditing strategy, an organization is effectively flying blind. If a sensitive document is deleted, a malicious actor gains access to a user account, or a configuration change compromises your security posture, you need a reliable trail to reconstruct the events. Audit logs are not just for reactive troubleshooting; they are a fundamental component of compliance, forensic investigations, and proactive security monitoring. Understanding how to configure, query, and manage these logs is a critical skill for any IT administrator or security analyst working in the Microsoft cloud ecosystem.
In this lesson, we will explore the Microsoft 365 Audit log architecture, how to enable and manage auditing, how to extract actionable intelligence from the data, and how to maintain compliance through rigorous reporting practices.
The Architecture of Microsoft 365 Auditing
Microsoft 365 uses a unified audit log that aggregates activities across various services, including Exchange Online, SharePoint Online, OneDrive for Business, Microsoft Teams, Azure Active Directory (now Microsoft Entra ID), and Power BI. This unification is significant because, in the past, logs were siloed within their respective applications. Today, an administrator can search for a user's activity across the entire suite from a single interface.
The Unified Audit Log (UAL)
The Unified Audit Log acts as a centralized repository for events. When an event occurs—such as a user signing in, a file being shared with an external guest, or a mailbox permission being modified—a record is generated. This record contains metadata, including the date and time, the user ID, the IP address, the service involved, and the specific operation performed.
Callout: The Difference Between Auditing and Logging While these terms are often used interchangeably, there is a technical distinction. "Logging" refers to the act of recording events as they happen. "Auditing" is the process of reviewing these logs to ensure that activities align with organizational policy, security requirements, and regulatory standards. You can have logs without auditing, but you cannot have effective auditing without logs.
Retention and Availability
One of the most important aspects of audit logging is understanding how long your data is kept. By default, Microsoft 365 retains audit logs for a limited period, which depends on the licensing level of your users. For users with standard licenses, this might be 90 days. For users with specific premium licenses (such as Microsoft 365 E5 or Office 365 E5), retention can be extended to one year or even ten years with the appropriate add-on licenses. It is vital to check your specific tenant configuration to ensure your retention policies meet your internal compliance requirements.
Enabling and Managing Audit Logging
Before you can search for logs, you must ensure that auditing is enabled in your tenant. While auditing is enabled by default for most organizations, it is a best practice to verify this, especially if you are managing a new or long-standing tenant where configurations may have drifted.
Verifying Audit Status
You can check the audit status using the Microsoft Purview compliance portal or through Exchange Online PowerShell. PowerShell is often the preferred method for administrators because it provides a direct, scriptable interface to the audit configuration.
Step-by-step: Checking Audit Status via PowerShell
- Connect to Exchange Online PowerShell using your administrator credentials.
- Run the following command:
Get-AdminAuditLogConfig | Select-Object UnifiedAuditLogIngestionEnabled - If the output returns
True, auditing is active. If it returnsFalse, you must enable it.
Step-by-step: Enabling Audit Logging
If you discovered that auditing is disabled, you can enable it with the following command:
Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true
Note: Enabling auditing does not retroactively create logs for events that occurred while the feature was disabled. It only begins recording events from the moment it is turned on. This is why regular audits of your audit configuration are essential.
Searching and Querying Audit Logs
Once your logs are flowing into the Unified Audit Log, the real work begins: finding the information you need. The Microsoft Purview compliance portal provides a graphical user interface (GUI) for searching logs, which is suitable for ad-hoc investigations. However, for large-scale reporting or automated analysis, PowerShell or the Office 365 Management Activity API is required.
Searching via the Purview Portal
The Purview portal allows you to filter by date range, activity type, user, and file or site. This is useful for simple queries, such as "Show me all files deleted by John Doe last week."
- Navigate to the Microsoft Purview compliance portal.
- Select Audit from the left-hand navigation.
- Use the search criteria to define your scope.
- Click Search to generate the results.
Searching via PowerShell
The Search-UnifiedAuditLog cmdlet is the workhorse for administrators. It allows for more precise filtering and the ability to export data for further processing in tools like Excel, Power BI, or a SIEM (Security Information and Event Management) system.
Example: Searching for file deletion events
Search-UnifiedAuditLog -StartDate (Get-Date).AddDays(-7) -EndDate (Get-Date) -Operations FileDeleted -ResultSize 5000
- Explanation: This command searches the last seven days for any "FileDeleted" operations. It returns up to 5000 results. You can further refine this by adding
-RecordType SharePointFileOperationto focus specifically on SharePoint/OneDrive activities.
Practical Examples of Audit Analysis
To truly understand the value of audit logging, we must look at how it helps in real-world scenarios.
Scenario 1: Identifying Unauthorized External Sharing
A common concern in organizations is the accidental or intentional sharing of sensitive documents with external guests. Audit logs can track the SharingInvitationCreated operation. By filtering for this operation, you can identify which users are sharing files and with whom.
Scenario 2: Detecting Unusual Sign-in Activity
Security teams often monitor UserLoggedIn and UserLoggedInFailed events. If a user account suddenly shows hundreds of failed login attempts followed by a successful one from an unusual IP address, this is a classic indicator of a credential stuffing or brute-force attack.
Scenario 3: Investigating Policy Violations
If an employee leaves the company and an administrator notices that important files were deleted or moved shortly before their departure, the audit log can confirm the exact timestamp of these actions and the specific items affected. This provides concrete evidence that can be used in internal investigations.
Warning: Be cautious when exporting large quantities of audit data. The
Search-UnifiedAuditLogcmdlet has a limit on the number of results it can return in a single request. If you need to export thousands of entries, you must use a script that implements pagination or uses the Office 365 Management Activity API, which is designed for high-volume data retrieval.
Best Practices for Audit Logging and Reporting
Managing audit logs is not a "set it and forget it" task. It requires a structured approach to ensure that your data is useful, secure, and compliant.
1. Implement a Log Retention Strategy
Do not rely on the default retention periods if your industry has specific regulatory requirements (such as HIPAA, GDPR, or SOX). If you are in a highly regulated industry, you may need to export logs to an external storage solution or a SIEM like Microsoft Sentinel for long-term retention beyond the one-year limit provided by Microsoft.
2. Monitor for "Audit Log Tampering"
While it is difficult for standard users to delete audit logs, privileged administrators have the capability. Always monitor for the Set-AdminAuditLogConfig or Remove-UnifiedAuditLog operations, as these could indicate an attempt by a malicious actor to cover their tracks.
3. Use Automation for Alerts
Searching logs manually is reactive. Proactive security involves setting up alerts for specific, high-risk activities. For example, you should be alerted immediately if someone adds a new global administrator, modifies a transport rule, or changes the password of a service account.
4. Regularly Review Audit Access
The ability to view audit logs is a sensitive permission. Follow the principle of least privilege. Only grant access to the "View-Only Audit Logs" or "Audit Logs" roles to those who absolutely need it for their job functions, such as compliance officers or security analysts.
5. Standardize Your Reporting
Create a library of pre-defined queries or scripts for common tasks. This ensures that when an investigation is needed, the team can pull the data quickly and consistently without needing to write new code under pressure.
Comparison of Auditing Methods
When deciding how to manage your logs, it helps to understand the different tools available to you.
| Method | Best For | Pros | Cons |
|---|---|---|---|
| Purview GUI | Ad-hoc searches | Easy to use, no code | Limited filtering, slow for large sets |
| PowerShell | Bulk export, automation | Precise control, scriptable | Requires coding knowledge |
| Microsoft Sentinel | Long-term analysis | Correlates logs, AI-driven | Requires additional setup/cost |
| Management API | Enterprise integration | Real-time streaming | High technical complexity |
Common Pitfalls and How to Avoid Them
Even experienced administrators can fall into traps when dealing with audit logs. Here are some of the most common mistakes:
Mistake 1: Ignoring the Latency
Audit logs are not always instantaneous. There can be a delay of anywhere from a few minutes to up to 24 hours between the time an action occurs and the time it appears in the log. If you are conducting a real-time investigation, keep in mind that the most recent actions might not be visible yet.
Mistake 2: Failing to Audit Enough (or Too Much)
If you do not audit enough, you will lack the evidence needed during an incident. If you audit every single minor action (like every time a file is viewed), you will create "log noise," making it difficult to find the truly important events. Focus your auditing strategy on high-value actions: permissions changes, deletions, logins, and configuration modifications.
Mistake 3: Not Protecting the Logs
If an attacker gains administrative access, the first thing they might do is disable auditing to hide their movements. Ensure that your audit logs are being streamed to an external, immutable storage location or a separate security monitoring platform where an attacker cannot reach them to delete them.
Mistake 4: Assuming All Activities are Logged
Not every single action in Microsoft 365 produces an audit log entry. While Microsoft is constantly expanding the list of audited events, there are still gaps. Always verify the Microsoft documentation to see which specific operations are supported for the services you are monitoring.
Callout: The Importance of Context An audit log entry by itself is just a data point. To make it meaningful, you need context. For example, a successful login from a new IP address is not inherently bad. However, if that login is followed immediately by an attempt to download the entire company directory, the context transforms a routine log entry into a high-priority security alert. Always look for patterns rather than isolated events.
Advanced Topic: Utilizing the Office 365 Management Activity API
For organizations that require deep integration with their existing security infrastructure, the Office 365 Management Activity API is the industry standard. This API allows you to pull audit data programmatically into your own data warehouse or SIEM.
How the API Works
The API works on a subscription model. You subscribe to specific content types (e.g., Audit.AzureActiveDirectory, Audit.Exchange, Audit.SharePoint) and then poll the API for new content. The API returns a list of JSON files containing the audit records.
Basic Workflow:
- Register an Application: Create an app registration in Microsoft Entra ID with the necessary permissions.
- Start a Subscription: Call the API to start receiving events for a specific content type.
- Poll for Content: Periodically request the list of available files from the API.
- Download and Process: Download the files and ingest them into your analysis system.
This method is far more efficient than PowerShell for large environments because it allows for continuous, automated streaming of data rather than manual, batch-based exports.
Designing a Compliance Reporting Workflow
A robust governance program is built on regular reporting. You should establish a cadence for reviewing audit data, even when there are no suspected incidents.
Monthly Compliance Report
- User Access Reviews: Identify all users who were added as administrators during the month.
- External Sharing Audit: Review all files shared externally to ensure they comply with data handling policies.
- Policy Modification Report: Check for any changes to organizational policies (e.g., mail flow rules, retention labels).
- Anomalous Activity Summary: Review any security alerts generated by the system.
By producing this report monthly, you demonstrate to auditors and stakeholders that the organization is actively monitoring its environment. It also helps you spot trends, such as a steady increase in external sharing, which might indicate a need for better user training or revised technical controls.
Integrating Audit Logs with Microsoft Sentinel
If your organization is looking to mature its security operations, integrating Microsoft 365 audit logs with Microsoft Sentinel is the recommended path. Sentinel is a cloud-native SIEM that uses machine learning to analyze the vast amounts of data produced by your audit logs.
Instead of manually searching for patterns, Sentinel can automatically flag "impossible travel" (e.g., a user logging in from New York and then from London within two hours) or detect signs of a compromised account based on behavioral baselines. This shifts the burden of analysis from the administrator to the system, allowing the IT team to focus on resolving threats rather than finding them.
Summary and Key Takeaways
Audit logging is the cornerstone of accountability and security in Microsoft 365. It provides the visibility required to maintain control over a complex, distributed cloud environment. By mastering the tools and strategies discussed in this lesson, you can move from a state of uncertainty to one of proactive governance.
Key Takeaways:
- Unified Visibility: The Unified Audit Log is your primary source of truth, consolidating events from across the Microsoft 365 stack into a single, searchable repository.
- Proactive Configuration: Always verify that audit logging is enabled and that your retention policies align with both your business needs and regulatory requirements.
- Tool Selection: Match your tool to the task. Use the Purview portal for quick investigations, PowerShell for specific, filtered data extraction, and the Management Activity API for enterprise-scale integration.
- Context is King: Audit data is most valuable when analyzed in context. Look for patterns, such as sequences of events, rather than focusing on isolated logs.
- Security of Logs: Protect your audit logs from tampering by ensuring that logs are exported to external, immutable storage or a centralized SIEM like Microsoft Sentinel.
- Automation: Minimize manual effort by automating the collection and alerting process. Relying on manual searches is unsustainable and prone to human error.
- Routine Auditing: Establish a regular reporting cadence to review access, policy changes, and anomalous activity, ensuring that your governance strategy is a living process rather than a static document.
By implementing these practices, you ensure that your organization remains resilient, compliant, and fully aware of the activities occurring within its digital workspace. Remember that the goal of auditing is not just to keep logs, but to foster a culture of transparency and accountability that protects the organization’s most important data.
Frequently Asked Questions (FAQ)
Q: Can I recover deleted audit logs? A: No. Once an audit log record is purged based on your retention policy, it cannot be recovered by Microsoft. This is why it is critical to export your logs to long-term storage if you need them for extended periods.
Q: Does auditing affect performance? A: No. The generation of audit logs happens on the backend servers of Microsoft 365. It does not impact the performance of the services for your end users.
Q: Why don't I see any results in my search? A: There are several reasons this could happen. First, ensure the search criteria are correct (check your dates). Second, remember there is a latency period for logs to appear. Third, ensure the specific activity you are looking for is actually audited by the service.
Q: What is the difference between an Audit Log and a Message Trace? A: An audit log tracks actions (who changed a setting, who deleted a file). A message trace tracks the delivery path of an email (did it reach the recipient, was it blocked by spam filters). They serve different purposes and are used in different scenarios.
Q: Can I audit "view" events in SharePoint?
A: Yes, but you must enable this explicitly. By default, "view" events are not always captured because they can generate a massive volume of data. You can enable them via the PowerShell command Set-SPOTenant -AuditLogTrimmingRetentionDays <value> and ensuring the appropriate audit settings are configured for your site collections.
Reach the last section to complete this lesson and earn points — you're on section 1 of 11.
- Introduction to Microsoft 365 Services
- Introduction to Microsoft 365 Services Quiz5q
- Cloud Concepts for Microsoft 365
- Cloud Concepts for Microsoft 365 Quiz5q
- Microsoft 365 Apps and Services Overview
- Microsoft 365 Apps and Services Overview Quiz5q
- Microsoft 365 Subscription Plans
- Microsoft 365 Subscription Plans Quiz5q
- Introduction to Microsoft 365 Agents
- Introduction to Microsoft 365 Agents Quiz5q
- Copilot Studio Overview
- Copilot Studio Overview Quiz5q
- Managing and Publishing Agents
- Managing and Publishing Agents Quiz5q
- Agent Security and Governance
- Agent Security and Governance Quiz5q
- Extending Copilot with Connectors
- Extending Copilot with Connectors Quiz5q
- Comprehensive Exam Strategies
- Comprehensive Exam Strategies Quiz5q
- M365 Services Key Concepts Review
- M365 Services Key Concepts Quiz5q
- Data Protection Key Concepts Review
- Data Protection Key Concepts Quiz5q
- Copilot Administration Key Concepts
- Copilot Administration Key Concepts Quiz5q
- AB-900 Final Practice Exam
- AB-900 Final Practice Exam Quiz5q
- Microsoft Graph API for Copilot
- Microsoft Graph API Quiz5q
Enjoying the courses?
Everything stays free. Pro shows fewer ads, doubles the points you earn on every lesson and quiz so you progress twice as fast, unlocks half of every practice exam — plus full case studies — with the Learn & Exam study modes, and lets you read each lesson on one page.
- ✓ Fewer advertisements
- ✓ 2× points per lesson & quiz
- ✓ 50% of every exam unlocked
- ✓ Learn & Exam modes
- ✓ Distraction-free lessons