Configure Syslog for VMware ESXi via vMA

I had originally written a post on doing this via PowerCLI and decided to add a post about using the VMware Management Assistant instead.

I did this with both vMA 5.5 and vMA 6.0 to confirm my script-fu.

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 Sumo Logic and is something I recommend highly.

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.

#!/bin/sh

#Update the following 3 variables.
#
# protocol: udp - the most common for syslog
# syslog server: destination server for syslog
# syslog port: 514 - the normal port for syslog. ESXi firewall also allows port 1514

SYSLOGPROTO="udp"
SYSLOGSERVER="my.server.name.com"
SYSLOGPORT=514

# set this to the server names you would like to update.

ESXIHOSTNAMES="this.hostanme.com that.hostname.com 172.31.22.173"

# Your vCenter system

VCENTER="vcenter.name.com"

# log into vCenter so we don't have to enter credentials all the time

vifptarget --set ${VCENTER}

# loop over ESXIHOSTNAMES and set the syslog destination

for i in ${ESXIHOSTNAMES}; do
  esxcfg-advcfg --vihost ${i} -set "${SYSLOGPROTO}://${SYSLOGSERVER}:{SYSLOGPORT}" Syslog.global.logHost
done

And that’s it.