public void WritingToUndeclaredSinkWritesToSelfLog() { Messages = new(); SelfLog.Enable(m => { Messages = Messages ?? new(); Messages.Add(m); }); var settings = new Dictionary <string, string> { ["write-to:DummyRollingFile.pathFormat"] = "C:\\" }; var log = new LoggerConfiguration() .ReadFrom.KeyValuePairs(settings) .CreateLogger(); DummyRollingFileSink.Reset(); DummyRollingFileAuditSink.Reset(); log.Write(Some.InformationEvent()); Assert.Single(Messages); Assert.Contains(Messages, m => m.EndsWith("Setting \"DummyRollingFile\" could not be matched to an implementation in any of the loaded assemblies. " + "To use settings from additional assemblies, specify them with the \"serilog:using\" key.")); }
static void ClearDummySinkStaticState() { DummyConsoleSink.Reset(); DummyAuditSink.Reset(); DummySink.Reset(); DummySinkWithComplexParams.Reset(); DummyRollingFileAuditSink.Reset(); DummyRollingFileSink.Reset(); DummySinkWithParams.Reset(); DummyWithLevelSwitchSink.Reset(); }
public void AuditSinksAreConfigured() { var settings = new Dictionary <string, string> { ["using:TestDummies"] = typeof(DummyLoggerConfigurationExtensions).GetTypeInfo().Assembly.FullName, ["audit-to:DummyRollingFile.pathFormat"] = "C:\\" }; var log = new LoggerConfiguration() .ReadFrom.KeyValuePairs(settings) .CreateLogger(); DummyRollingFileSink.Reset(); DummyRollingFileAuditSink.Reset(); log.Write(Some.InformationEvent()); Assert.Empty(DummyRollingFileSink.Emitted); Assert.Single(DummyRollingFileAuditSink.Emitted); }
public void AuditSinksAreConfigured() { var json = @"{ ""Serilog"": { ""Using"": [""TestDummies""], ""AuditTo"": [{ ""Name"": ""DummyRollingFile"", ""Args"": {""pathFormat"" : ""C:\\""} }] } }"; var log = ConfigFromJson(json) .CreateLogger(); DummyRollingFileSink.Reset(); DummyRollingFileAuditSink.Reset(); log.Write(Some.InformationEvent()); Assert.Equal(0, DummyRollingFileSink.Emitted.Count); Assert.Equal(1, DummyRollingFileAuditSink.Emitted.Count); }