< Back

Add-FileLogChannel

Tue Jan 14, 2020 3:24 am

NAME Add-FileLogChannel



SYNOPSIS

Adds a File Channel to the LoggingChannelList list





SYNTAX

Add-FileLogChannel [-FilePath] <String> [[-LogFormat] <String>] [-Append] [-Force] [<CommonParameters>]





DESCRIPTION

The Add-FileLogChannel cmdlet adds a Channel to the LoggingChannelList list that is capable of logging to a file.



If the file does not exist an empty file will be created.

If the file exists and the Append switch is not specified the file will be removed and a new empty file will be

created.





PARAMETERS

-FilePath <String>

Specifies the path of the file to which the logging should be writen.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LogFormat <String>

Specifies the format of the logging.

The LogFormat string will be formatted using the String format operator. (default: '{0:yyyy-MM-dd

hh:mm:ss.fff} - {1} [{2}] ({3}): {4}')

0:DateTime, 1:Source, 2:LogLevel, 3:ID, 4:Message



Required? false

Position? 2

Default value {0:yyyy-MM-dd hh:mm:ss.fff} - {1} [{2}] ({3}): {4}

Accept pipeline input? false

Accept wildcard characters? false



-Append [<SwitchParameter>]

Specifies that if the file exists all logging should be appended to it.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Force [<SwitchParameter>]

Specifies that if the file exists it should be forcefully removed.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-FileLogChannel "C:\\tmp\\script.log" -Force













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Add-FileLogChannel "C:\\tmp\\script.log" '{0:yyMMddhhmmss} [{2}({3})] {4}'















RELATED LINKS