Exchange 2013 : IIS 8 – change default log directory

Seing as Exchange 2013 generates a lot of logging by its various services running under IIS it can in many cases be a good idea to move the default log location to a seperate drive. You can even split up the logs from Default Web Site and the Exchange Back End like by making a seperate folder for each. As default they both log in %SystemDrive%\inetpub\LogFiles but another approach could be something like:

L:\IIS\LogFiles\DefaultWebSite
L:\IIS\LogFiles\ExchangeBackEnd

In this post I’m moving default log path to the same path, but on drive L:
Note: Remember to move the location of the Exchange Back end files as well.

  1. Open IIS and open Default Web Site and dobbelt-click Logging
    01
  2. Here you can either use the Browse… button or just manually type in the desired path.
    Click on Apply located in the upper right-hand corner when done.
    02
  3. When clicking Apply.. you are met with a pop-up notifaction, reminding you that it might take a while before you see any activity in your new logging destination.
    03
  4. Remember to make the same changes for Exchange Back End. Here is the end result:
    01-3
  5. You should either move or copy your existing logs to the new location, when IIS starts using the new location.
Setting IIS logging path Using Powershell

We are used to PowerShell automatically loading the needed modules after PowerShell 3.0 but since we are only indrectly using the WebAdministration for targeting a specific ‘drive’ (IIS in this case), we have to import the module ourselves.

We can see how the IIS drive isn’t available untill we load the WebAdministration Module

Get-PSDrive | Where-Object {$_.name -eq 'iis'}
07

Armed with this knowledge, lets set a new location for our logfile.directory

Heres is the command for moving the Logfiles for the Default Web Site. I am using -verbose as I would otherwise get no output on successfull completion.

Import-Module WebAdministration
Set-ItemProperty 'IIS:\Sites\Default Web Site' -name logfile.directory "L:\IIS\LogFiles\DefaultWebSite" -verbose

09-defaultwebsite
Here is the command for moving the Logfiles for Exchange Back End.

Import-Module WebAdministration
Set-ItemProperty 'IIS:\Sites\ExchangeBackEnd' -name logfile.directory "L:\IIS\LogFiles\ExchangeBackEnd" -verbose

08-backend

Here the new paths are shown in IIS
10-defaultiis
11-defaultiis

More on the topic of Logging:

Logging to Event Tracing for Windows in IIS 8.5 
In IIS 8.5, the administrator has the option of sending logging information to Event Tracing for Windows (ETW).

Event Tracing.

MessageAnalyzer
All things about Message Analyzer and related diagnosis for Networks, Log files, and Windows Components
Capture ETW events created by IIS or ASP.NET which include the request URL.

Microsoft-Windows-HttpService {DD5EF90A-6398-47A4-AD34-4DCECDEF795F}

Look at the Deliver event. It has RequestUrl, and the app pool the request got forwarded to.
Source of this last one.

Posted in Exchange 2013, IIS, IIS, Powershell, Server 2012

Leave a Reply