Skip to content

Instantly share code, notes, and snippets.

@rsgoheen
rsgoheen / gist:ba5fb610396b09e4481e
Created February 27, 2015 13:44
Using Serilog in a PowerShell script
Add-Type -Path "Serilog.dll"
Add-Type -Path "Serilog.Sinks.Seq.dll"
Add-Type -Path "Serilog.Sinks.EventLog.dll"
Add-Type -Path "Serilog.FullNetFx.dll"
Add-Type -Path "Serilog.Extras.AppSettings.dll"
Add-Type -Path "Serilog.Extras.Timing.dll"
$Config = New-Object Serilog.LoggerConfiguration
[Serilog.Configuration.LoggerSinkConfiguration]$ConfigSink = $config.WriteTo
[Serilog.Log]::Logger = [Serilog.LoggerConfigurationFullNetFxExtensions]::RollingFile($ConfigSink, "C:\Logs\Log-{Date}.txt", ([Serilog.Events.LogEventLevel]::Verbose), "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}", $null, 10000000, 15).CreateLogger()
@rsgoheen
rsgoheen / gist:33c38a37768722f2f811
Last active August 29, 2015 14:01
Linq to XML with namespaces
public static class LogQueueHelper
{
public const string exampleXml =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<events version=""1.2"" xmlns=""http://logging.apache.org/log4net/schemas/log4net-events-1.2"">
<event domain=""MessageDomain"" level=""INFO"" logger=""Logger"" thread=""AMQP Connection amqp-0-9://localhost:5672"" timestamp=""2014-05-08T13:16:02.6990183+01:00"" username=""rsgoheen"">
<message>LogMessage</message>
<properties>
<data name=""log4net:Identity"" value=""""/>
set-location -Path C:\
$Shell = $Host.UI.RawUI
$size = $Shell.WindowSize
$size.width=150
$size.height=50
$Shell.WindowSize = $size
$size.Width=150
$size.Height=3000