Configuring Virtual Machine vmware.log File Rotation
The vmware.log file contains virtual machine specific logging. The vmware.log file is stored in the same virtual machine directory as the virtual machine configuration file (virtualmachine.vmx). By default the vmware.log file is only rotated when a virtual machine is restarted and 6 old logs are kept.
Generally unless there is an issue with a VM these logs do not become very large nor do they grow very fast so the default should be fine in most cases. If you do want to control the size and number of logs kept (a compliance requirement or what have you) it has to be configured on each virtual machine.
Setting log.rotateSize and log.keepOld
To add or edit these configurations the Virtual machine must be powered off. Using the vSphere client Edit Settings of the virtual machine, select the Options tab, under Advanced select General, and click on the “Configuration Parameters…” button. Select “Add Row” and in the name field type log.rotateSize. In the value field specify the file rotation size, for 1MB enter 1000000.
To change the number of logs to keep click the “Add Row” button again and enter log.keepOld to the name field. In the value field set the number of old logs you want to keep. If you want to keep 3 old logs set this value to 3.
You can also add these options by editing the VM’s .vmx file and add the following lines:
log.rotateSize = “1000000”
log.keepOld = “3”
There is a VMwareKB on Log rotation and logging options for vmware.log but the KB does not reference vSphere 5. The configurations are the same on vSphere 5. The KB references that 3 old log files are kept by default, I am not sure when this changed but with out setting up log.keepOld 6 old log files are being kept. Not sure in what version this may have changed or if there is somewhere else this can be set.
Does anyone know of away to set this globally for all VMs? You can set the options on a template and any VMs deployed using that template will have the options set, but is there a way to set this by default on any VM created?
What about setting it using PowerCLI? Check out this post on Setting/Modifying Advanced VM Options using PowerCLI to set log rotation and number of old logs to keep with PowerCLI.
Hi Hersey,
You stated above”Generally unless there is an issue with a VM these logs do not become very large..”
I’ve noticed a .log file for a VM 500MB in size, isn’t it unusual and what issues for example can be reason for generating such large log file?
Thanks.
Misho,
Best thing to do is look into the log and see what is going on.
Have you opened the file to see what is in it? Easiest way to do this is to SSH to the hosts, change directory to /vmfs/volumes/DATASTORE_VM_IS_ON/VM_DIRECTORY, and then use tail or less to view what is being written (tail -f vmware.log) to the file or what is in (less vmware.log) the file (if the file is very large do not try to use open the file with an editor, vi or what have you, on the host). The log files can also be copied to a workstation and opened in an editor using SCP or the Datastore Browser in the vSphere Client. I do not typically see these log files get larger than a few MB, unless there is an issue. The logs also rotate whenever a VM is powered off and back on to create vmware-x.log.
Hope this helps.
Hersey
Hello Hersey,
I am trying to collect vmware.log file for particular VM in order to investigate an issue around it.
I tried to copy/download the same from the folder of the VM in the data store browser, but it doesn’t work.
Please reply how could I collect the same?
Many thanks.
I have not tried this it looks like it should do exactly what you are looking to do: http://www.lucd.info/2011/02/27/virtual-machine-logging/
Thanks
Hersey