public void should_escape_invalid_filename_chars_windows() { ParsedLayout pl = ParsedLayout.ParseFileName("C:\\temp\\logs\\{TimeStamp}{NL}.log"); FileTarget file = (new FileTargetBuilder()).Build() as FileTarget; Logger logger = Logger.Create(file); string text = Body(pl, new LoggerEvent { SourceLogger = logger }); Assert.Equal("C:\\temp\\logs\\0001-01-01_00_00_00Z_.log", text); }
public void Body_should_expand_environment_variables() { Environment.SetEnvironmentVariable("MYHOME", "Hello"); ParsedLayout pl = ParsedLayout.ParseFileName("%MYHOME%/the.log"); FileTarget file = (new FileTargetBuilder()).Build() as FileTarget; Logger logger = Logger.Create(file); string text = Body(pl, new LoggerEvent { SourceLogger = logger }); Assert.Equal("Hello/the.log", text); }