It seems a custom logging format is ignored, but still acts as if it is set when you call Get-LoggingDefaultFormat. It does not make a difference if I set the default format before or after adding a target
PS C:\> Get-LoggingDefaultFormat
[%{timestamp:+%Y-%m-%d %T%Z}] [%{level:-7}] %{message}
PS C:\> Add-LoggingTarget -Name Console
PS C:\> Write-Log -Level INFO -Message "Test"
[2019-09-04 16:47:09-04] [INFO ] Test
PS C:\> Set-LoggingDefaultFormat -Format "%{timestamp:+yyyy-MM-dd HH:mm:ss.fff},%{level},%{message}"
PS C:\> Write-Log -Level INFO -Message "Test"
[2019-09-04 16:47:28-04] [INFO ] Test
PS C:\> Set-LoggingDefaultFormat -Format "%{+yyyy-MM-dd HH:mm:ss.fff},%{level},%{message}"
PS C:\> Write-Log -Level INFO -Message "Test"
[2019-09-04 16:47:43-04] [INFO ] Test
PS C:\> Write-Log -Level ERROR -Message "Test"
[2019-09-04 16:47:56-04] [ERROR ] Test
PS C:\> Get-LoggingDefaultFormat
%{+yyyy-MM-dd HH:mm:ss.fff},%{level},%{message}
PS C:\> Set-LoggingDefaultFormat -Format "[%{timestamp:+%Y-%m-%d}] [%{level}] %{message}"
PS C:\> Write-Log -Level ERROR -Message "Test"
[2019-09-04 16:53:43-04] [ERROR ] Test
PS C:\> Get-LoggingDefaultFormat
[%{timestamp:+%Y-%m-%d}] [%{level}] %{message}
The pester tests all pass for Replace-Token so I think it has something to do with the formatting of the message in the Write-Log function. I haven't been able to dig into the source yet.
I am running:
- PS v5.1.17763.503
- Windows 10 1809 x64 Enterprise
- Logging module version 4.2.3
It seems a custom logging format is ignored, but still acts as if it is set when you call
Get-LoggingDefaultFormat. It does not make a difference if I set the default format before or after adding a targetThe pester tests all pass for
Replace-Tokenso I think it has something to do with the formatting of the message in theWrite-Logfunction. I haven't been able to dig into the source yet.I am running: