Separating Sitecore Audit Logs into a Dedicated Log File in Sitecore 10.4

 Introduction

In a Sitecore implementation, application, publishing, and audit messages are often written to the standard Sitecore log files. When troubleshooting or reviewing user activities, finding audit-related entries in a large Sitecore log can become time-consuming.

A simple approach to address this is to configure a dedicated Audit Log file that captures Sitecore AUDIT entries separately.

This provides a cleaner and more manageable way to review activities such as content updates, publishing, and user actions without having to search through the complete Sitecore log.

What is Sitecore Audit Logging?

Sitecore generates audit-related log entries for various activities performed within the Sitecore application.

For example:

AUDIT (sitecore\Admin): Save item: master:/sitecore/content/Home/Sample Item,
language: en, version: 1, id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

This entry provides useful information such as:

  • User who performed the action

  • Action performed

  • Database

  • Item path

  • Language

  • Version

  • Item ID

  • Time of the activity

Publishing actions can also generate entries such as:

AUDIT (sitecore\Admin): Publish item: master:/sitecore/content/Home/Sample Item,
language: en, version: 1, id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

This makes the audit log useful when investigating content changes and publishing activities.

Do We Need to Enable Audit Logging?

For Sitecore 10.4, there is no need to introduce a separate custom mechanism just to start generating the standard Sitecore audit information.

The proposed configuration does not enable a new audit mechanism. Instead, it takes the existing AUDIT entries generated by Sitecore and routes them to a dedicated log file.

Therefore, the purpose of the configuration patch is log separation, not enabling audit functionality.

Why Separate the Audit Log?

Keeping audit entries in a dedicated file provides several benefits.

1. Easier Troubleshooting

Instead of searching through large Sitecore logs, administrators can directly open:

App_Data\logs\Audit.log.{date}.txt

and review audit-related activity.

2. Easier User Activity Tracking

The audit entries can help identify which user performed actions such as:

  • Saving content

  • Publishing content

  • Other Sitecore audit activities

3. Easier Monitoring

A dedicated audit file can be monitored independently from the standard Sitecore logs.

4. No Additional Database Logging

If the requirement is only to maintain the audit information in a file, there is no need to configure an SQL appender.

The proposed configuration writes the audit entries only to the dedicated log file.

Configuration Patch

The recommended approach is to create a separate patch file rather than modifying the Sitecore configuration directly.

Suggested location:

App_Config\Include\zzz\zzz.AuditLog.config

The configuration can be:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
               xmlns:x="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <log4net>

      <!-- Audit / Publishing log file -->
      <appender name="AuditLogFileAppender"
                type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">

        <file value="$(dataFolder)/logs/MuseumAudit.log.{date}.txt" />

        <!-- AUDIT messages -->
        <filter type="log4net.Filter.StringMatchFilter">
          <stringToMatch value="AUDIT" />
          <acceptOnMatch value="true" />
        </filter>

        <!-- Publishing messages -->
        <filter type="log4net.Filter.StringMatchFilter">
          <stringToMatch value="[Publishing]" />
          <acceptOnMatch value="true" />
        </filter>

        <!-- PublishOptions messages -->
        <filter type="log4net.Filter.StringMatchFilter">
          <stringToMatch value="[PublishOptions]" />
          <acceptOnMatch value="true" />
        </filter>

        <!-- Reject everything else -->
        <filter type="log4net.Filter.DenyAllFilter" />

        <appendToFile value="true" />
        <rollingStyle value="Date" />
        <maxSizeRollBackups value="-1" />

        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
        </layout>

        <encoding value="utf-8" />

      </appender>

      <!-- Root logger -->
      <root>
        <priority value="INFO" />
        <appender-ref ref="AuditLogFileAppender" />
      </root>

      <!-- Audit logger -->
      <logger name="AuditLogFileAppender" additivity="false">
        <level value="INFO" />
        <appender-ref ref="AuditLogFileAppender" />
      </logger>

      <!-- Sitecore Publishing logger -->
      <logger name="Sitecore.Diagnostics.Publishing" additivity="false">
        <level value="INFO" />
        <appender-ref ref="AuditLogFileAppender" />
      </logger>

    </log4net>
  </sitecore>
</configuration>  

Why Use Only the AUDIT Filter?

Sitecore publishing can generate different types of log messages, including:


These messages are useful for publishing troubleshooting, but they are not necessarily required when the objective is to maintain a clean audit trail.

The AUDIT entries themselves already provide useful information about the activity.

For example:

AUDIT (sitecore\Admin): Save item: master:/sitecore/content/Home/Sample Item,
language: en, version: 1, id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

and:

AUDIT (sitecore\Admin): Publish item: master:/sitecore/content/Home/Sample Item,
language: en, version: 1, id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

Therefore, using only the AUDIT filter keeps the dedicated file focused on audit activity.

Log File Location

After applying the patch, the audit log will be generated under:

<Data Folder>\logs\Audit.log.{date}.txt

For example:

App_Data\logs\Audit.log.2026-08-23.txt

The log file will roll based on the configured date-based rolling strategy.

SQL Appender Is Not Required

If the requirement is to store audit information only in files, an SQL appender should not be configured.

The following should not be included:

<appender name="ADONetAppender_SqlServer" ...>

and:

<appender-ref ref="ADONetAppender_SqlServer"/>

This ensures that the audit entries are not additionally inserted into a SQL Log table.

The flow is therefore:

Sitecore Activity
       ↓
   AUDIT Event
       ↓
AuditLogFileAppender
       ↓
Audit.log.{date}.txt

Example Audit Entries

Content Save

AUDIT (sitecore\Admin): Save item:
master:/sitecore/content/Home/Sample Item,
language: en, version: 1,
id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

Content Publish

AUDIT (sitecore\Admin): Publish item:
master:/sitecore/content/Home/Sample Item,
language: en, version: 1,
id: {3ABBD7F1-9C9A-442A-8899-5DE37BFB9B65}

These entries allow the team to identify the user, action, item, language, version, and timestamp associated with the activity.

Validation

After deploying the configuration patch to the CM server, perform a few test activities:

  1. Log in to Sitecore.

  2. Modify and save a test item.

  3. Publish the test item.

  4. Check the audit log under:

App_Data\logs\Audit.log.{date}.txt
  1. Verify that the expected AUDIT entries are present.

  2. Confirm that the standard Sitecore log is no longer the only place where these audit entries need to be searched.

  3. Confirm that no SQL logging is configured for the audit appender.

Conclusion

Separating Sitecore audit entries into a dedicated log file provides a simple way to improve audit visibility and troubleshooting.

The approach does not introduce a new audit mechanism. Instead, it uses the existing Sitecore audit events and routes the AUDIT entries to:

App_Data\logs\Audit.log.{date}.txt

For Sitecore 10.4, this provides a cleaner separation between audit activity and the broader Sitecore application logs, while avoiding unnecessary SQL-based audit logging when file-based logging is sufficient.

Comments

Popular posts from this blog

Configuring Custom Media Domain in Sitecore XP 10 + Next.js

Building a CMS-Agnostic Layout Service Response in Sitecore

Sitecore 10.4 + Docker + Next.js: A Complete Setup Guide for JSS Developers