I'm trying to understand how to use SeriLog in PS.
This is an example of code that works:
$SeriLog = Add-Type -Path "C:\Program Files\PackageManagement\Serilog.2.10.0\lib\net46\Serilog.dll" -PassThru
$SeriLog_Sink_Console = Add-Type -Path "C:\Program Files\PackageManagement\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll" -PassThru
$SeriLog_Config = New-Object Serilog.LoggerConfiguration
$SeriLog_Config = [Serilog.Configuration.LoggerSinkConfiguration]$SeriLog_Config_Sink = $SeriLog_Config.WriteTo
[Serilog.Log]::Logger = [Serilog.ConsoleLoggerConfigurationExtensions]::Console($SeriLog_Config_Sink).CreateLogger()
[Serilog.Log]::Information("Logging started")
Based on examples listed on SeriLogs site for dotnet, what i don't understand is why are all my sinks missing.
Example:
$SeriLog = Add-Type -Path "C:\Program Files\PackageManagement\Serilog.2.10.0\lib\net46\Serilog.dll" -PassThru
$SeriLog_Sink_Console = Add-Type -Path "C:\Program Files\PackageManagement\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll" -PassThru
$SeriLog_Config = New-Object Serilog.LoggerConfiguration
$SeriLog_Config.WriteTo.Console()
There error i get is:
InvalidOperation: Method invocation failed because [Serilog.Configuration.LoggerSinkConfiguration] does not contain a method named 'Console'.
This makes sense to a degree in that I can see it's missing, but I don't understand why? I've imported both DLL's. I guess for me, I'm very much a newbie when it comes to understanding how to work with DLL's in PS. I've had much better luck with and have a reliably working module with Log4Net, but I'm trying to migrate to something that's more modern and I'm pulling my hair out trying to understand how to integrate various sinks if the public examples for dotnet don't translate to PS.
JFYI, I'm using PS 7.1 incase that matters.