Skip to content

Commit 3a1ae27

Browse files
committed
Documentation: Part 1 (README and Write-ToLog)
1 parent e708226 commit 3a1ae27

File tree

2 files changed

+81
-10
lines changed

2 files changed

+81
-10
lines changed

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,39 @@ You can easily translate toast notifications by creating your locale xml config
5151
WAU runs ,by default, at logon. You can configure the frequency with options (Daily, BiDaily, Weekly, BiWeekly, Monthly or Never).
5252

5353
### Log location
54-
You can find logs in install location, in logs folder for priviledged executions. For user runs (Winget-Install.ps1) a log file will be created at %AppData%\Winget-AutoUpdate\Logs .<br>
55-
If **Intune Management Extension** is installed, a **SymLink** (WAU-updates.log) is created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs**<br>
56-
If you are deploying winget Apps with [Winget-Install](https://github.com/Romanitho/Winget-AutoUpdate/blob/main/Sources/Winget-AutoUpdate/Winget-Install.ps1) a **SymLink** (WAU-install.log & WAU-user_%username%.log) is also created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs**
54+
You can find logs in the install location, in **logs** folder for priviledged executions (after the first run of WAU).
55+
56+
For user runs of **Winget-Install.ps1** a log file will be created at **%AppData%\Winget-AutoUpdate\Logs**.
57+
58+
If **Intune Management Extension** is installed, **SymLinks** (**WAU-updates.log**/**WAU-install.log**) are created under **C:\ProgramData\Microsoft\IntuneManagementExtension\Logs**.
59+
60+
Later experience sadly confirms that **Intune Management Extension** keeps its folder to itself, cleaning it from time to time!
61+
62+
#### Comprehensive Logging System
63+
WAU uses a comprehensive logging system that writes to three different destinations simultaneously:
64+
65+
1. **Standard Log File**:
66+
- Simple text-based logs with timestamps
67+
- Easily readable format for general troubleshooting
68+
- Located in the installation directory's logs folder
69+
70+
2. **Configuration Manager (CM) Log Format**:
71+
- Compatible with Microsoft's CMTrace and CMLogViewer tools
72+
- Detailed log format with component, context, source, thread ID, and log level information
73+
- Automatically created if CMTrace or CMLogViewer is detected on the system
74+
- File name ends with "_CM.log"
75+
76+
3. **Windows Event Log**:
77+
- Entries are written to the Application log under the "WAU" source
78+
- Different event IDs based on the operation (installs, uninstalls, modifications, updates, errors)
79+
- Integrates with centralized event log monitoring solutions
80+
81+
Logs are automatically rotated when they reach the configured size limit (default 1MB), with a configurable number of historical log files kept (default 3).<br>
82+
You can adjust these settings with the MAXLOGFILES and MAXLOGSIZE parameters during installation.
83+
84+
All log destinations support different log levels (1=Information, 2=Warning, 3=Error) and the console output uses color coding for easier reading, with headers for important sections.
85+
86+
CMTrace and CMLogViewer support log level 0 and 4 (Verbose, None).
5787

5888
### "Unknown" App version
5989
As explained in this [post](https://github.com/microsoft/winget-cli/issues/1255), Winget cannot detect the current version of some installed apps. We decided to skip managing these apps with WAU to avoid retries each time WAU runs:

Sources/Winget-AutoUpdate/functions/Write-ToLog.ps1

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,57 @@
1-
# Standard use (all three destinations)
2-
# Write-ToLog "Installing $AppID..." "DarkYellow"
1+
<#
2+
.SYNOPSIS
3+
Writing to log files and console with formatting and color options.
34
5+
.DESCRIPTION
6+
This function handles logging to multiple destinations - standard log file, Configuration Manager log file, Windows Event Log, and console output.
7+
It supports color-coded output, headers, and different log levels.
8+
9+
.PARAMETER LogMsg
10+
The message to log.
11+
12+
.PARAMETER LogColor
13+
The color to use for console output.
14+
Available colors: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White
15+
16+
.PARAMETER IsHeader
17+
Switch to format the message as a header with surrounding '#' characters.
18+
19+
.PARAMETER Component
20+
The component name to use in Configuration Manager log format.
21+
22+
.PARAMETER LogLevel
23+
The log level to use:
24+
0 = Verbose
25+
1 = Information (default)
26+
2 = Warning
27+
3 = Error
28+
4 = None
29+
30+
.PARAMETER LogSource
31+
The source name for the Windows Event Log.
32+
33+
.PARAMETER UseCMLog
34+
Whether to use Configuration Manager log format.
35+
36+
.PARAMETER UseEventLog
37+
Whether to write to the Windows Event Log.
38+
39+
.EXAMPLE
40+
# Standard use (all three destinations)
41+
Write-ToLog "Installing $AppID..." "DarkYellow"
42+
43+
.EXAMPLE
444
# Extra Configuration Manager details
5-
# Write-ToLog -LogMsg "Installing $AppID..." -LogColor "DarkYellow" -Component "AppInstaller" -LogLevel "1"
45+
Write-ToLog -LogMsg "Installing $AppID..." -LogColor "DarkYellow" -Component "AppInstaller" -LogLevel "1"
646
47+
.EXAMPLE
748
# With Event Log
8-
# Write-ToLog -LogMsg "Debug information" -LogColor "Gray" -UseEventLog
49+
Write-ToLog -LogMsg "Debug information" -LogColor "Gray" -UseEventLog
950
51+
.EXAMPLE
1052
# As header
11-
# Write-ToLog "NEW INSTALL REQUEST" "RoyalBlue" -IsHeader -Component "WinGet-Install"
12-
13-
# Color options: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White
53+
Write-ToLog "NEW INSTALL REQUEST" "RoyalBlue" -IsHeader -Component "WinGet-Install"
54+
#>
1455

1556
function Write-ToLog {
1657
param (

0 commit comments

Comments
 (0)