Skip to content

If I try to rename Timestamp header in LoggingProvider writing JSON files, then datetime values is written odly #672

Open
@tejl

Description

@tejl

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)/"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions