Home Virtualization Using PowerCLI to Set Log Rotation Options for a Group of Virtual Machines

Using PowerCLI to Set Log Rotation Options for a Group of Virtual Machines

by admin

I recently had the need to increase the log retention for the vmware.log file. By default, 6 versions (or rotations) of the VMware.log file are available. A new vmware.log file gets created for a virtual machine each time it is powered on.

The settings that control the log file behavior are set on a per-VM basis, and are documented here. For my purposes, I needed to change the ‘log.keepOld‘ setting. The setting can be changed by editing the .vmx file, or by using the vSphere client to add the new setting, by adding a row to the configuration parameters for the VM:

configuration-parameters

The problem with changing the setting using the client, or by editing the .vmx file, is that it will be time consuming if a number of VMs need to have the setting applied.

An alternative approach is to use PowerCLI to apply the setting. For a single virtual machine, this can be done with:

Get-VM virtualmachine | New-AdvancedSetting –Name “log.keepOld” –value “10”

To apply the changes to all VMs in a cluster, for example, you could use:

Get-Cluster clustername | Get-VM | New-AdvancedSetting –Name “log.keepOld” –value “10”

Once configured, the defined number of old vmware.log files will be retained:

/vmfs/volumes/4f27b82e-3fc1540e-bf6b-000c295da2d9/XP # ls -lah *vmware*
-rw-r--r-- 1 root root 107.8K Sep 3 2013 vmware-10.log
-rw-r--r-- 1 root root 107.9K Sep 3 2013 vmware-11.log
-rw-r--r-- 1 root root 107.9K Sep 3 2013 vmware-12.log
-rw-r--r-- 1 root root 107.9K Sep 3 2013 vmware-3.log
-rw-r--r-- 1 root root 107.8K Sep 3 2013 vmware-4.log
-rw-r--r-- 1 root root 108.0K Sep 3 2013 vmware-5.log
-rw-r--r-- 1 root root 107.8K Sep 3 2013 vmware-6.log
-rw-r--r-- 1 root root 107.8K Sep 3 2013 vmware-7.log
-rw-r--r-- 1 root root 107.9K Sep 3 2013 vmware-8.log
-rw-r--r-- 1 root root 107.9K Sep 3 2013 vmware-9.log
-rw-r--r-- 1 root root 107.8K Sep 3 2013 vmware.log

Note that if you change this setting, it is advisable to also configure the maximum size of each log file, using the ‘log.rotateSize’ setting.

Useful Links and Resources

https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=8182749

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More