Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serilog.Sinks.EventLog fails Windows validation in .Net Foundation 4.8.1 #49

Open
brentbiggs opened this issue Aug 16, 2023 · 0 comments

Comments

@brentbiggs
Copy link

Basic functional test failing on PS 5.1, but works with PS 7.3. Other tested serilog.sinks (File, Console) function as expected.

Error seems to be centered around this line:

throw new PlatformNotSupportedException(RuntimeInformation.OSDescription);

Failed case with PowerShell 5.1 .NET Foundation 4.8.1:

PS C:\> $serilog = Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\PoShLog\2.1.1\lib\Serilog.dll" -PassThru
PS C:\> $serilogEventLog = Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\PoShLog.Sinks.EventLog\1.0.0\lib\Serilog.Sinks.Eventlog.dll" -PassThru
PS C:\> $config = New-Object Serilog.LoggerConfiguration
PS C:\> [Serilog.LoggerConfigurationEventLogExtensions]::EventLog($Config.WriteTo,'Application')                                                             Exception calling "EventLog" with "2" argument(s): "EventLog access is not supported on this platform." 
At line:1 char:1
+ [Serilog.LoggerConfigurationEventLogExtensions]::EventLog($Config.Wri ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PlatformNotSupportedException
PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Passed case with PowerShell 7.3.4 .NET 7:

PS C:\> $serilog = Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\PoShLog\2.1.1\lib\Serilog.dll" -PassThru
PS C:\> $serilogEventLog = Add-Type -Path "C:\Program Files\WindowsPowerShell\Modules\PoShLog.Sinks.EventLog\1.0.0\lib\Serilog.Sinks.Eventlog.dll" -PassThru
PS C:\> $config = New-Object Serilog.LoggerConfiguration
PS C:\> [Serilog.LoggerConfigurationEventLogExtensions]::EventLog($Config.WriteTo,'Application')

WriteTo      : Serilog.Configuration.LoggerSinkConfiguration
AuditTo      : Serilog.Configuration.LoggerAuditSinkConfiguration
MinimumLevel : Serilog.Configuration.LoggerMinimumLevelConfiguration
Enrich       : Serilog.Configuration.LoggerEnrichmentConfiguration
Filter       : Serilog.Configuration.LoggerFilterConfiguration
Destructure  : Serilog.Configuration.LoggerDestructuringConfiguration
ReadFrom     : Serilog.Configuration.LoggerSettingsConfiguration


PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant