Ola Hallengren: Output File

I’m a huge fan of Ola Hallengren‘s free utility scripts. If you aren’t familiar with it, it’s a great tool to manage backups, index maintenance and the overall health of your SQL Servers. It is utilized around the globe and it is completely free.

Although his script is very thorough I still like to tweak and One of the things that I tend to change is the way that the log file for each respective job is named.  By default, the file name is configured in the following format:


which results in file names that look like this:

If you have never looked, these files contain information about any failures or issues the job(s) might have encountered.  The difficult part is that when looking at the list, how do you know which file belongs to which job?  In the example above, one is a FULL backup, a DIFF backup and the third a TRAN LOG backup but it is difficult to determine which is which.  However, you can see that each JobID is a unique identifier, which correlates to the job ID of the specific job.

There are two ways to adjust this.

  1.  Update the maintenance script itself to adjust the file names.  In the script, configuration of job logging starts approximately on line 4127.  Your mileage may vary depending on which version you have.  You can look for the phrase “Log completing information” in the file to determine where it starts.  Once you find its location, you can adjust the file name to however you want.
  2. If you don’t want to adjust the script,  you can use the script below to manually adjust the output file name.  This script will produce the appropriate parameters for sp_update_jobstep.  You can then copy/paste the command into a query windows and execute in a controlled manner.

Once adjusted, the log files are will be much easier to read, as shown below.  I can now quickly differentiate the log files not only between databases but also types.




© 2017, John Morehouse. All rights reserved.

2 Replies to “Ola Hallengren: Output File”

  1. you might want to keep the id incase of aliens (ie. job runs from another instance/replica onto a shared dir). the key is to keep the *_*_*_*.txt so the cleanup will pick it up at the -30.

    well nicely done, sir.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.