/// <summary> /// Renders the specified environment variable and appends it to the specified <see cref="StringBuilder" />. /// </summary> /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param> /// <param name="logEvent">Logging event.</param> protected override void Append(StringBuilder builder, LogEventInfo logEvent) { if (this.Variable != null) { var layout = new SimpleLayout(EnvironmentHelper.GetSafeEnvironmentVariable(this.Variable)); builder.Append(layout.Render(logEvent)); } }
/// <summary> /// Renders the specified environment variable and appends it to the specified <see cref="StringBuilder" />. /// </summary> /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param> /// <param name="logEvent">Logging event.</param> protected override void Append(StringBuilder builder, LogEventInfo logEvent) { if (this.Variable != null) { var environmentVariable = EnvironmentHelper.GetSafeEnvironmentVariable(this.Variable); if (!string.IsNullOrEmpty(environmentVariable)) { var layout = new SimpleLayout(environmentVariable); builder.Append(layout.Render(logEvent)); } else { if (this.Default != null) { var layout = new SimpleLayout(this.Default); builder.Append(layout.Render(logEvent)); } } } }
public void WrapLineMultipleTimesTextLengthNotMultipleTest() { SimpleLayout l = "${message:wrapline=3}"; var le = LogEventInfo.Create(LogLevel.Info, "logger", "foobarba"); Assert.Equal("foo" + System.Environment.NewLine + "bar" + System.Environment.NewLine + "ba", l.Render(le)); }