# $cs.Job_DisableLog

> Turns off logging for all subsequent calls, until $cs.Job_EnableLog is called. Commonly used to suppress noisy or expected-to-fail log entries around a single check.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-job-disablelog/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Turns off logging for all subsequent calls, until [$cs.Job_EnableLog](/capainstaller/powerpacks/cs-job-enablelog/) is called. Commonly used to suppress noisy or expected-to-fail log entries around a single check.

### Syntax

$cs.Job\_DisableLog(string text = null)

### Parameters

#### text (String)

Optional text to write to the log once, before logging is switched off. If omitted, nothing is logged.

### Return value

None

### Example

**PowerShell**

Suppress logging around a single check that would otherwise write a noisy "not found" entry:

```powershell
$cs.Job_DisableLog("Temporarily disabling logging while checking for optional component")
$installed = $cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')
$cs.Job_EnableLog("Re-enabling logging")
```

Suppress logging around a loop that probes several optional features, each of which is expected to fail for most machines:

```powershell
$cs.Job_DisableLog("Silencing log while probing optional Windows features")
$optionalFeatures = @("TFTP", "TelnetClient", "SNMP")
$installedFeatures = foreach ($feature in $optionalFeatures) {
  $state = Get-WindowsOptionalFeature -Online -FeatureName $feature -ErrorAction SilentlyContinue
  if ($state -and $state.State -eq 'Enabled') { $feature }
}
$cs.Job_EnableLog("Finished probing optional features: $($installedFeatures -join ', ')")
```

Wrap the suppressed section in `try`/`finally` so logging is guaranteed to be re-enabled even if the check throws an unexpected error:

```powershell
try {
  $cs.Job_DisableLog("Silencing log while checking for a flaky optional dependency")
  $installed = $cs.MSI_IsMSIGuidInstalled('{AC76BA86-1033-FF00-7760-BC15014EA700}')
} finally {
  $cs.Job_EnableLog("Re-enabling logging")
}
```

### Related functions

[$cs.Job_EnableLog](/capainstaller/powerpacks/cs-job-enablelog/)
