lukeglazebrook
Enthusiast
Enthusiast

Adding Syslog logging level possible?

Hi All,

Thanks in advance for any help you can provide, I already have a cool bit of PowerCLI that will configure the host Syslog servers in my environment.  I was however wondering if anyone is aware of how I can add to this and also tweak amend the logging level effectively editing the config.xml (which is required from my understanding ...

VMware vSphere 6.5 Documentation Library

The script I have been using to add add a specific syslog server ...

write-Host "Loading Automation Tools"

Add-PSSnapin VMware.VimAutomation.Core

# Establish Connection

Connect-VIServer -Server SecretServer.co.uk -User Luke@SecretDomain -Password TopSecretIWouldHaveToKillYouIfYouSawMe

Foreach ($vmhost in (get-vmhost))

{

$esxcli = Get-EsxCli -vmhost $vmhost

$esxcli.system.syslog.config.get()

}

Foreach ($vmhost in (get-vmhost))

{

$esxcli = Get-EsxCli -vmhost $vmhost

$esxcli.system.syslog.config.set($null, $null , $null, $null, $null, $null, $null, $null, “udp://Blah:514,udp://Blah:514,udp://svr0123:514”, $null, $null);

$esxcli.network.firewall.ruleset.set($null, $true, “syslog”)

$esxcli.system.syslog.reload()

}

Reply
0 Kudos
LucD
Leadership
Leadership

Not with a direct command afaik.
You have to edit the config.xml file.

I normally do that via a SSH connection and the Posh-Ssh module, with a sed command.

This changes the loglevel from warning to error.

$cmdSub = 'sed -i -e ''s?<logLevel> warning </logLevel>?<logLevel> error </logLevel>?g'' /etc/vmware/hostd/config.xml'

$esxName = 'MyEsx'


$cred = Get-Credential -Message "SSH crdentials for ESXi node $esxName"


$session = New-SSHSession -ComputerName $esxName -Credential $cred –AcceptKey

$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub

Remove-SSHSession -SSHSession $session | Out-Null

.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos