Managing IIS Log File Storage (2024)

  • Article

by Jim van de Erve

You can manage the amount of server disk space that Internet Information Services (IIS) log files consume by using compression, remote storage, and scripted deletion.

Overview

The log files that IIS generates can, over time, consume a large amount of disk space. Logs can potentially fill up an entire hard drive. To mitigate this problem, many users turn off logging completely. Fortunately, there are alternatives to doing so, such as the following:

  • Enable folder compression
  • Move the log folder to a remote system
  • Delete old log files by script.

The above mitigations are described in the sections below. You may also want to do the following to control disk usage:

  • Limit log size by omitting unneeded property fields
  • Create separate logs for Web sites and applications
  • Preserve memory resources by using centralized binary logging.

For more information, see Configuring Logging in IIS.

Enable Folder Compression

IIS log files compress to about 2% of their original size. Enable compression of a log file as follows. You must be an administrator to perform this procedure.

  1. Click the File Manager icon in the icon bar.
  2. Move to the folder containing IIS log files (by default, %SystemDrive%\inetpub\logs\LogFiles).
  3. Right-click on the folder and click Properties.
  4. On the General tab of the Properties page, click Advanced.
  5. Click Compress contents to save disk space, and then click OK.Managing IIS Log File Storage (1)
  6. Click Apply, and then select whether to compress the folder only, or the folder, its subfolders, and its files.
  7. Click OK. Verify that the folder contents are compressed. The name of the folder and the name of each file should be colored blue, and the size of a compression file should be smaller.

This is a simple way to lower disk usage. It is not a final solution, however, because disk usage still grows over time, and could eventually fill up the hard drive.

If the folder already contains a significant amount of data, it could take the computer a while to compress its contents. Also note that this one-time process could slow down the computer during the initial compression, so if this is a production server, perform this operation during off-peak hours to prevent service degradation.

Move the Log Folder to a Remote System

IIS log files are stored by default in the %SystemDrive%\inetpub\logs\LogFiles folder of your IIS server. The folder is configured in the Directory property on the Logging page for either the server or an individual site. To lessen the problem of log disk usage, you can move your IIS log files to a folder on another server that has more space. This server can either be in the same domain as the local IIS server, or a different domain. You can save log files remotely either for the entire server or for individual Web sites.

This solution can help the security of the system, because if a local hard drive crashes, the log data is still available on remote storage. In addition, the log files can be consumed by analysis systems.

Change the location of an IIS log file to a remote share as follows:

  1. Create a log-file directory on a remote server that is in the same domain as your local Web server running IIS.

  2. In the folder's Properties page, on the Sharing tab, click Share so that the directory is shared. On the Security tab, assign groups and users with the appropriate permissions. Ensure that the appropriate groups and users are able to read and write to the log files.Managing IIS Log File Storage (2)

    For more information, see Configuring Permissions for Remote Logging.

    Note: If you want to write log files to a remote server in a different domain, see Setting Up a Null Session for Cross-Domain Logging.

  3. Open IIS Manager on your local Web server.

  4. In IIS Manager, in the Connections pane, click the server or a Web site.

  5. Double-click Logging.Managing IIS Log File Storage (3)

  6. In the Directory text box, enter the full UNC path of the directory that you created on the remote server. For example, type \servername\Logs, where "servername" represents the name of the remote server, and "Logs" represents the name of the share where the log files are stored.Managing IIS Log File Storage (4)

  7. In the Actions pane, click Apply, and then click OK. All Web sites within the directory should begin logging data to the remote share.

    For more information, see Remote Logging.

Delete Old Log Files by Script

You can control disk usage of log files by running a script that automatically deletes log files that are older than a certain age. Running this script in a scheduled task will keep the problem of a disk filling up under control without constant maintenance.

The following VBScript will check the age of each log file in a folder and will delete any log file older than a specified age. To customize the script for your purposes, simply change the name and path of the folder in line 1 of the script, and change the maximum age to the desired value in days, in line 2.

sLogFolder = "c:\inetpub\logs\LogFiles"iMaxAge = 30 'in daysSet objFSO = CreateObject("Scripting.FileSystemObject")set colFolder = objFSO.GetFolder(sLogFolder)For Each colSubfolder in colFolder.SubFolders Set objFolder = objFSO.GetFolder(colSubfolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles iFileAge = now-objFile.DateCreated if iFileAge > (iMaxAge+1) then objFSO.deletefile objFile, True end if NextNext

The script above will scan all subfolders, so it will process logs for ALL sites in and under the folder specified. If you want to limit the process to just a single site, change the path appropriately.

To run the script manually, execute the following script in an administrator command line: cscript.exe c:\scripts\retentionscript.vbs

Using a script to delete log files is a long-term, reliable solution to the problem of log files consuming disk space. If you automate the process, as shown below, it doesn't require constant maintenance.

Run the script as a scheduled task

You can automate the task of deleting log files by script by creating a Windows task schedule to run the script periodically. You can schedule the script to run at any time using the Windows Task Scheduler. How you configure the scheduled task should be coordinated with the configuration of the log file rollover options.

  1. Open Server Manager, click the Tools menu, and then click Task Scheduler.
  2. In the Actions pane of the Task Scheduler dialog box, click Create Task.Managing IIS Log File Storage (5)
  3. On the General tab of the Create Task dialog box, enter a name for the task, such as "Delete Log Files". Set the security properties, selecting a user account with sufficient privileges to run the script.Managing IIS Log File Storage (6)
  4. Click the Triggers tab, and then click New. In the New Trigger dialog box, set Begin the task to On a schedule. Select the periodicity, for example, Daily. Enter the Start date, select more advanced settings, and ensure that Enabled is selected if you are ready to initiate the schedule. Click OK.Managing IIS Log File Storage (7)
  5. Click the Actions tab, and then click New. In the New Action dialog box, select a value for Action, in this case, Start a program. In Program/script, enter cscript, and in Add arguments (optional), enter the path and name of the script file, for example, C:\iis\Log\_File\_Deletion.vbs. Click OK.Managing IIS Log File Storage (8)
  6. Click OK.
  7. Verify that the task has been added to the Active Tasks pane.
  8. Right-click on the new task, and select Run.Managing IIS Log File Storage (9)
  9. Navigate to the folder that the script ran on, and verify that the appropriate log files were deleted.
  10. Navigate back to the Task Scheduler, right-click on the task, and click End so the status returns to Ready and the task is ready for scheduled runs.
Managing IIS Log File Storage (2024)

FAQs

How do I reduce IIS log files? ›

Move to the folder containing IIS log files (by default, %SystemDrive%\inetpub\logs\LogFiles ). Right-click on the folder and click Properties. On the General tab of the Properties page, click Advanced. Click Compress contents to save disk space, and then click OK.

Is it OK to delete IIS log files? ›

Managing IIS Log File Storage

They are just log files. If you aren't needing them for logging then yeah, you can remove them.

How to clean up inetpub logs? ›

And the recommended process to delete these files is:
  1. Launch a command prompt using Run as administrator.
  2. Stop IIS with below command: iisreset /stop.
  3. Browse to C:\inetpub\logs\Logfiles\W3SVC1 folder in Windows Explorer.
  4. Delete the log files.
  5. Start IIS with below command.
May 9, 2022

Where are the IIS log files stored? ›

IIS Logs Location: On a standard Windows Server, IIS log files are found at %SystemDrive%\inetpub\logs\LogFiles by default.

How do I reduce log files? ›

Truncate the transaction log
  1. Right-click the database and select Properties -> Options.
  2. Set the recovery model to Simple and exit the menu.
  3. Right-click the database again and select Tasks -> Shrink -> Files.
  4. Change the type to Log .
  5. Under Shrink action, select Reorganize pages before releasing unused space and click OK.

How big are IIS logs? ›

By default, each IIS Site hosted will begin recording web logs into %SystemDrive%inetpublogsLogFiles and it will create a new file every day. For some sites, this isn't a big deal as the file might only be 10KB – 1000KB in size, but for others, each of these files can balloon to over 100MB per day.

What is stored in IIS logs? ›

IIS web server log files contain helpful information that organizations can use to evaluate the performance of their websites and services. These logs include user activity, error reports, and business details that aid in pinpointing the root cause of performance issues.

Do I need to keep log files? ›

It is recommended that you archive your logs centrally to ensure their integrity and compliance. Based on the business requirements, log type, and anticipated search needs you may not always be able to affordably store all log types into a central repository but proper storage cost analysis can help these decisions.

Are log files important? ›

A log file provides a detailed and easily accessible record of system information that would otherwise be difficult to collate. It provides insight into the performance and compliance of your applications and systems. Log files are crucial for cloud applications because of their dynamic and distributed features.

What is the best way to clean logs? ›

We recommend cleaning logs with a combination of water and a wood-friendly detergent, i.e. TSP (Trisodium Phosphate Cleaner). We want to stress that we DO NOT recommend power-washing logs to clean them. Applying water under high pressure can be detrimental to the “health” of a log building.

Where are the Inetpub logs stored? ›

Go to Windows File Explorer > C Drive > Inetpub folder > Logs folder > LogFiles.

How do I clear server logs? ›

In this article
  1. Click Start, and point to Programs.
  2. Point to Administrative Tools, and then click Event Viewer.
  3. Select the appropriate log file (Application, Security, System, Directory Service, or File Replication Service).
  4. Click the Action menu, and then click Clear all Events.
  5. You will be prompted to save the file.
Apr 19, 2022

Can I delete IIS LogFiles? ›

These IIS log files are indeed safe to delete. Please refer to the following guide to locate and delete these log files: Navigate to C:\inetpub\logs\LogFiles\W3SVC1 and delete all of the .

What information can be captured in an IIS log file? ›

Contents of the IIS Log
Field NameDescription
Date and Time (date and time)Date and time of client request
Client IP Address (c-ip)IP address of the website client
Username (cs-username)User making the request. Anonymous users are represented by a hyphen “-”
Method (cs-method)HTTP request (such as GET, POST, PUT)
5 more rows
Dec 21, 2022

How to disable IIS logs? ›

Resolution:
  1. Open IIS.
  2. Highlight the server name.
  3. Under the IIS heading, click on "Logging"
  4. On the actions pane one the right, click "Disable".
  5. Exit IIS.
  6. Navigate to "C:\inetpubs\logs"
  7. Delete that folder or all of the contents of logfiles. ( W3SVCx folders)
  8. Empty recycle bin if necessary.

How do I recycle IIS logs? ›

  1. Open IIS Manager on the IdP appliance and expand the server name | Application Pools.
  2. Right Click the application pool for which it is desired to log recycle events (this will usually be the pool named ". ...
  3. Expand "Generate Recycle Event Log Entry" then set the desired child nodes to True, then click OK.
Nov 16, 2018

How do I shrink database logs automatically? ›

Users can enable and disable database auto shrink option using SSMS and T-SQL both ways.
  1. Activating the database auto shrink by using SSMS:
  2. Enable database auto shrink using T-SQL:
  3. Database >> Reports >> Standard Reports >> Disk Usage.
  4. Check free space for the database files:
  5. Shrink database file:
Mar 5, 2020

How do I change IIS log settings? ›

Configure Logging at the Site Level
  1. Open IIS Manager. ...
  2. In the Connections tree view, select your website.
  3. In Features View, double-click Logging.
  4. On the Logging page, in the Log file section under Format, select one of the following log file formats: ...
  5. Under Directory, specify the path where the log file should be stored.
May 9, 2020

Top Articles
What to pack in a carry-on bag for flight: Your questions answered
HashRouter v6.26.2
123Movies Encanto
Palm Coast Permits Online
Libiyi Sawsharpener
Ffxiv Palm Chippings
Euro (EUR), aktuální kurzy měn
Boomerang Media Group: Quality Media Solutions
Coffman Memorial Union | U of M Bookstores
Es.cvs.com/Otchs/Devoted
Practical Magic 123Movies
What Auto Parts Stores Are Open
Stl Craiglist
Arrests reported by Yuba County Sheriff
Teamexpress Login
Fnv Turbo
Best Cav Commanders Rok
Hardly Antonyms
Bros Movie Wiki
Palace Pizza Joplin
Studentvue Columbia Heights
Lancasterfire Live Incidents
Invert Clipping Mask Illustrator
Labby Memorial Funeral Homes Leesville Obituaries
Zoe Mintz Adam Duritz
Www Craigslist Com Bakersfield
Hewn New Bedford
Babbychula
Watertown Ford Quick Lane
Culver's.comsummerofsmiles
Truvy Back Office Login
Narragansett Bay Cruising - A Complete Guide: Explore Newport, Providence & More
Farm Equipment Innovations
Paradise Point Animal Hospital With Veterinarians On-The-Go
Page 2383 – Christianity Today
Deepwoken: Best Attunement Tier List - Item Level Gaming
Robert A McDougal: XPP Tutorial
Kacey King Ranch
Fairwinds Shred Fest 2023
NIST Special Publication (SP) 800-37 Rev. 2 (Withdrawn), Risk Management Framework for Information Systems and Organizations: A System Life Cycle Approach for Security and Privacy
Sedano's Supermarkets Expands to Orlando - Sedano's Supermarkets
Lichen - 1.17.0 - Gemsbok! Antler Windchimes! Shoji Screens!
Snohomish Hairmasters
Thanksgiving Point Luminaria Promo Code
Daly City Building Division
Noaa Marine Weather Forecast By Zone
No Boundaries Pants For Men
Top 40 Minecraft mods to enhance your gaming experience
Rise Meadville Reviews
Epower Raley's
ats: MODIFIED PETERBILT 389 [1.31.X] v update auf 1.48 Trucks Mod für American Truck Simulator
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5583

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.