Are you running out of disk space on your Microsoft Exchange Server? If so, enabling circular logging may be the answer.

Circular logging in Exchange Server is a feature that limits the Exchange transactional log to a reasonable size to avoid overwhelming the storage volume it's located on. When enabling circular logging, however, the transactional log can only grow to 1 MB in size with the first log file being overwritten by the last-in-first-out (LIFO) queue.

Enabling Circular Logging with PowerShell ^

There are two ways to enable circular logging on a mailbox database in Exchange Server 2016: via PowerShell or via the Exchange Admin Center. Let's first see how to do this with PowerShell.

To enable circular logging with PowerShell, we need to define the name of the database that we're going to be enabling it for. In this article, I'll be using a mailbox database name of TechSnipsDemoDB, so I'll assign it to a variable called $MailboxDatabase so I can reference it multiple times.

$MailboxDatabase = 'TechSnipsDemoDB'

After doing this, I'll create a simple helper function to gather up some stats for the drive my log files are stored on to compare the before-and-after stats and run that.

Function Get-DBPathStats{

Function Get-DBPathStats{
    $DBPath = Get-Item 'E:\ExDBs'
    $DBPath | Get-ChildItem | Measure-Object -Sum Length | Select-Object @{Name="Path"; Expression={$DBPath.FullName}},@{Name="Files"; Expression={$_.Count}},@{Name="Size"; Expression={"$($_.Sum/1MB) MB"}}
Finding log volume size

Finding log volume size

Now that I have a before-picture of what the volume looks like, I can use the Set-MailboxDatabase cmdlet to enable circular logging on our mailbox database. I'll provide the cmdlet the name of the mailbox database and then use the CircularLoggingEnabled parameter setting it to $true to tell the cmdlet that we do want to enable circular logging on this database.

Set-MailboxDatabase $MailboxDatabase -CircularLoggingEnabled $true

After running Set-MailboxDatabase, you will see a warning telling you that you need to remount the database.

Remount mail database

Remount mail database

The easiest way to remount the database is to restart the MSExchangeIs service on the Exchange server. I'll do this by running Restart-Service.

Remounting the mail database

Remounting the mail database

After remounting the database, I can now run my custom function Get-DBPathStats again, and you should see that the log has decreased in size.

Enabling circular logging with the Exchange Admin Center ^

We can also enable circular logging via the Exchange Admin Center by navigating to the servers option on the left, selecting the databases tab, finding the database we want to edit and then clicking on the edit option.

Editing the mailbox database

Editing the mailbox database

Once in the database area, select the maintenance option, scroll to the bottom, and you'll see an option to enable circular logging.

Enabling circular logging

Enabling circular logging

The screenshot above shows the option as already enabled since we just enabled it with PowerShell.

Subscribe to 4sysops newsletter!

Wrap-up ^

Circular logging isn't as conventional as it once was due to the increased storage capacity of volumes nowadays with the fact of reduced restoration windows. But when you need the option, you now know how to do it using PowerShell and the Exchange Admin Center.


Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2021


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account