Skip to content

Commit 4c628c7

Browse files
committed
Fixes error while writing too large eventlog msges
1 parent 054459c commit 4c628c7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
4343
* [#159](https://github.com/Icinga/icinga-powershell-framework/pull/159) Fixes crash during update of the Icinga Framework, caused by the newly introduced experimental feature for code caching
4444
* [#165](https://github.com/Icinga/icinga-powershell-framework/pull/165) Fixes fetching for Icinga Agent certificate for REST-Api daemon on upper/lower case hostname mismatch
4545
* [#166](https://github.com/Icinga/icinga-powershell-framework/pull/166) Fixes fetching of Icinga Agent MSI packages by correctly comparing versions to ensure we always use the latest version and fixes `release` usage for local/network drive sources
46+
* [#167](https://github.com/Icinga/icinga-powershell-framework/pull/167) Fixes error while writing EventLog entries with too large message size
4647

4748
## 1.2.0 (2020-08-28)
4849

lib/core/logging/Write-IcingaEventMessage.psm1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ function Write-IcingaEventMessage()
5151
return;
5252
}
5353

54+
[int]$MaxEventLogMessageSize = 30000;
55+
56+
if ($EventLogMessage.Length -ge $MaxEventLogMessageSize) {
57+
while ($EventLogMessage.Length -ge $MaxEventLogMessageSize) {
58+
$CutMessage = $EventLogMessage.Substring(0, $MaxEventLogMessageSize);
59+
Write-EventLog -LogName Application `
60+
-Source 'Icinga for Windows' `
61+
-EntryType $EntryType `
62+
-EventId $EventId `
63+
-Message $CutMessage;
64+
65+
$EventLogMessage = $EventLogMessage.Substring($MaxEventLogMessageSize, $EventLogMessage.Length - $MaxEventLogMessageSize);
66+
}
67+
}
68+
69+
if ([string]::IsNullOrEmpty($EventLogMessage)) {
70+
return;
71+
}
72+
5473
Write-EventLog -LogName Application `
5574
-Source 'Icinga for Windows' `
5675
-EntryType $EntryType `

0 commit comments

Comments
 (0)