File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -79,14 +79,17 @@ logger management and how to log the log messages.
79
79
Start-ScriptLogger
80
80
81
81
# Second options, specify multiple custom settings for the logger
82
- Start-ScriptLogger -Path 'C:\Temp\test.log' -Format '{0:yyyy-MM-dd} {0:HH:mm:ss} {1} {2} {3,-11} {4}' -Level Warning -NoEventLog -NoConsoleOutput
82
+ Start-ScriptLogger -Path 'C:\Temp\test.log' -Format '{0:yyyy-MM-dd} {0:HH:mm:ss} {1} {2} {3,-11} {4}' -Level Warning -Encoding 'UTF8' -NoEventLog -NoConsoleOutput
83
83
84
84
# Get the current script logger configuration object
85
85
Get-ScriptLogger
86
86
87
87
# Update the script logger configuration
88
88
Set-ScriptLogger -Level Verbose
89
89
90
+ # Log an error record
91
+ try { 0 / 0 } catch { Write-ErrorLog -ErrorRecord $_ }
92
+
90
93
# Log an error message
91
94
Write-ErrorLog -Message 'My Error Message'
92
95
Original file line number Diff line number Diff line change 3
3
Start-ScriptLogger
4
4
5
5
# Second options, specify multiple custom settings for the logger
6
- Start-ScriptLogger - Path ' C:\Temp\test.log' - Format ' {0:yyyy-MM-dd} {0:HH:mm:ss} {1} {2} {3,-11} {4}' - Level Warning - Encoding ' UTF7 ' - SkipEventLog - HideConsoleOutput
6
+ Start-ScriptLogger - Path ' C:\Temp\test.log' - Format ' {0:yyyy-MM-dd} {0:HH:mm:ss} {1} {2} {3,-11} {4}' - Level Warning - Encoding ' UTF8 ' - NoEventLog - NoConsoleOutput
7
7
8
8
# Get the current script logger configuration object
9
9
Get-ScriptLogger
10
10
11
11
# Update the script logger configuration
12
12
Set-ScriptLogger - Level Verbose
13
13
14
+ # Log an error record
15
+ try { 0 / 0 } catch { Write-ErrorLog - ErrorRecord $_ }
16
+
14
17
# Log an error message
15
18
Write-ErrorLog - Message ' My Error Message'
16
19
You can’t perform that action at this time.
0 commit comments