JT.WriteLog

2.2.0.0


Write-Log is a Powershell logging script.

Write-Log write the log on the console with color and create a 'Log' folder  for the log file. The default name of the log is "{Scriptname}_log.txt".

The console color for the log:

ErrorLevel              Color
----------              ----------
INFO                    White
SUCCESS                 Green
WARNING

Write-Log is a Powershell logging script.

Write-Log write the log on the console with color and create a 'Log' folder  for the log file. The default name of the log is "{Scriptname}_log.txt".

The console color for the log:

ErrorLevel              Color
----------              ----------
INFO                    White
SUCCESS                 Green
WARNING                 Yellow
ERROR                   Red
DEBUG                   DarkYellow

Usage:
Write-Log [-errorLevel] {INFO | SUCCESS | WARNING | ERROR | DEBUG} [[-message] <String>] [[-logRecycling]
   {Continue | Daily | Hourly}] [[-logPath] <String>] [-debugMode] [<CommonParameters>]
Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name JT.WriteLog

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name JT.WriteLog

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2024 Johnny Tse. All rights reserved.

Package Details

Author(s)

  • Johnny Tse

Functions

Write-Log

Dependencies

This module has no dependencies.

Release Notes


Version 2.0.0.2:    Bug fix: Write-Log created log file using module name when instead of {ScriptName}.
                   Enhance: It can use $LengthOfFunctionName to adjust the lenght of the 'Function Name' field.
Version 2.0.0.3:    Fix: Correct EXAMPLE message.
Version 2.0.0.4:    Bug fix: Failure to write file under PowerShell v5.1 or below version.
Version 2.1.0.0:    Bug fix: The log file location may be incorrect.
                   Enhance: Add '<Job>' after the function name field to identify it is call from [Start-Job] / [Start-ThreadJob].
                            Auto adjust the length of 'Function Name' for write message into log file.
                            Standardize encoding (to UTF8) between Powershell 5.1 and Powershell Core.
Version 2.2.0.0:    Enhance: Improve performance if it did not have write to file or display debug information.

FileList

Version History

Version Downloads Last updated
2.2.0.0 (current version) 11 4/16/2025
2.1.0.0 22 3/7/2025
2.0.0.4 8 3/3/2025
2.0.0.3 17 2/26/2025
2.0.0.1 10 1/9/2025