Configure syslog for VMware ESXi via PowerCLI

This is actually very easy to do, especially if you are using vCenter.

This may need VMware PowerCLI 5.x/6.x as I never did this in earlier editions and do not remember seeing these cmdlets.

VMware ESXi supports syslog over both TCP and UDP (most common). Centralized logging is a huge win when debugging problems and there are many ways to do this. One commercial package is Splunk and I’d recommend it if you can afford it.

This script also has the benefit of changing the logging level from verbose to info which will cut the amount of logging being sent to your syslog server. You can always reset it later if you are doing deep debugging.

# change VCENTER to your vCenter DNS name or IP
# if you are not authenticated then it will prompt you for authentication

# replace VCENTER with the name or IP address of your vCenter system, or
#   your ESXi system
# replace SYSLOG with your syslog IP address, also take into account the
#   syslog port you wish to use

Connect-VIServer VCENTER

# This will automatically configure all hosts with the same syslog
# destination

get-vmhost | Set-VMHostAdvancedConfiguration -NameValue @{'Config.HostAgent.log.level'='info';'Vpx.Vpxa.config.log.level'='info';'Syslog.global.logHost'='udp://SYSLOG:514'}

And there you have it!

This post has an example of how to set this using VMware Management Assistant if you’d rather do it without PowerCLI.