Brainfarts Uncategorized Managing Log files

Managing Log files

This post was most recently updated on December 11th, 2018

Exchange: Managing SMTP and IIS Log Files via Script
Summary:

 

Exchange can can log a number of transactions such as SMTP, IIS, or Message Tracking. These logs play an important role in troubleshooting, trending as well as a number of other things. However, Exchange or IIS does not provide an option to automatically purge SMTP or IIS logs. In this article, I will provide an example to manage these log files.

Procedure:

Since you want to always keep a copy of your log files, for example 30 days worth before purging them, what this script will do is first move all log files from the directory you specify to another partition E:\\logs that are older than 30 days, then delete any log files older than 60 days from E:\\logs.

You can find all files required to run this process from ftp://ftp.smtp25.org/[ James Chong Scripts ]

1. Create a folder in C:\\scripts (Or anywhere you want to designate)

2. Download WaRmZip from SoureForge. http://sourceforge.net/project/showfiles.php?group_id=88417&package_id=99571 Download file to C:\\scripts

3. Open notepad and enter the following:

:: movelogs.bat
:: moves log files from the directory you specify below
::
@ECHO OFF

C:
CD\\scripts\\waRmZip16

waRmZip.wsf /r /q “C:\\logs” /ma:30 /md:E:\\Logs_Old

This script will move any log files older than 30 days from C:\\logs to E:\\logs_old folder. You will need to modify this line to point to where your SMTP or IIS logs are and your destination path. Save this file as movelogs.bat

4. Open notepad and copy the following:

:: deletelogs.bat
:: Delete logs older than 60 days to run every 60 days.
::
@ECHO OFF

C:
CD\\scripts

waRmZip.wsf /r “E:\\Logs_Old” /da:60 /df /q

Save this file as deletelogs.bat

5. Now go to scheduled tasks and schedule movelogs.bat to run monthly and deletelogs.bat to run every 60 days.

Note: Ensure you test this using test directories before implementing them into production.

Related Post