Open
Description
This configuration works and time values are written as e.g. "Timestamp":"2025-04-29 12:30:32"
$jsonLoggingProvider = @{
Name = 'logfile'
InstanceName = 'JsonProvider'
FilePath = 'D:\logs\json\joblog-%Date%.json'
FileType = 'json'
Enabled = $true
Wait = $true
JsonString = $true
Encoding = 'UTF8'
MutexName = 'jsonProvider'
TimeFormat = 'yyyy-MM-dd HH:mm:ss'
Headers = 'Timestamp', 'File as ScriptFile', 'Level', 'Line', 'Message', 'FunctionName', 'ModuleName', 'ComputerName', 'Runspace', 'Tags', 'TargetObject', 'Type', 'Username'
LogRotatePath = 'D:\Logs\json\joblog-*.json'
}
If I try this configuration (see changes in Headers)
$jsonLoggingProvider = @{
Name = 'logfile'
InstanceName = 'JsonProvider'
FilePath = 'D:\logs\json\joblog-%Date%.json'
FileType = 'json'
Enabled = $true
Wait = $true
JsonString = $true
Encoding = 'UTF8'
MutexName = 'jsonProvider'
TimeFormat = 'yyyy-MM-dd HH:mm:ss'
Headers = 'Timestamp as _timestamp', 'File as ScriptFile', 'Level', 'Line', 'Message', 'FunctionName', 'ModuleName', 'ComputerName', 'Runspace', 'Tags', 'TargetObject', 'Type', 'Username'
LogRotatePath = 'D:\Logs\json\joblog-*.json'
}
then values are written as: "_timestamp":{"value":"/Date(1745922216099)/"