WriteLog

0.9.11

Apteco PS Modules - PowerShell logging script

Execute commands like

Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log

The logfile getting written looks like

20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ER
Apteco PS Modules - PowerShell logging script

Execute commands like

Write-Log -message "Hello World"
Write-Log -message "Hello World" -severity ([LogSeverity]::ERROR)
"Hello World" | Write-Log

The logfile getting written looks like

20210217134552 a6f3eda5-1b50-4841-861e-010174784e8c INFO Hello World
20210217134617 a6f3eda5-1b50-4841-861e-010174784e8c ERROR Hello World

separated by tabs.

Make sure, the variables $logfile and $processId are present before calling this. Otherwise they will be created automatically and you are notified about the location and the current process id
The variables could be filled like

$logfile = ".\test.log"
$processId = [guid]::NewGuid()

The process id is good for parallel calls/processes so you know they belong together
Show more

Minimum PowerShell version

5.1

Installation Options

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

Install-Module -Name WriteLog -RequiredVersion 0.9.11

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

Install-PSResource -Name WriteLog -Version 0.9.11

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) 2022 Apteco GmbH. All rights reserved.

Package Details

Author(s)

  • florian.von.bracht@apteco.de

Tags

Windows Apteco

Functions

Write-Log Get-Logfile Set-Logfile Get-ProcessId Set-ProcessId Resize-Logfile Get-LogfileOverride Get-ProcessIdOverride

PSEditions

Desktop Core

Dependencies

This module has no dependencies.

Release Notes


0.9.11 Fixed missing public function declarations
0.9.10 Added two functions to find out if default logfile and processid have been overriden
      Now setting the filename and processid earlier
0.9.9 Removed dependency of New-TemporaryFile
     Removed the hints to logfile path and process id. This will be automatically set and can be overridden
0.9.8 Fixing a problem with accidental removed dashes
0.9.7 Changed formatting and resolved some hints from PSScriptAnalyzer
0.9.6 Changed warning output to verbose information
0.9.5 Changing Write-Output to Write-Information an tag the streams instead for Default and Info
0.9.4 Removed dependencies on variables and added getter/setter functions instead
0.9.3 Adding a function to clean a logfile (keep only latest n rows)
     Conversion of script to module
0.9.2 Updated description and removed the return value because it can cause problems in c# calling the script
0.9.1 Initial release of logging module through psgallery

FileList

Version History

Version Downloads Last updated
0.9.12 485 6/6/2024
0.9.11 (current version) 5 6/4/2024
0.9.10 6 6/4/2024
0.9.9 5 6/4/2024
0.9.8 183 8/22/2023
0.9.7 7 8/21/2023
0.9.6 71 11/21/2022
0.9.5 20 10/31/2022
0.9.4 15 10/27/2022
0.9.3 14 10/27/2022
Show more