Ejemplo n.º 1
0
 /// <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));
     }
 }
Ejemplo n.º 2
0
        /// <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));
	                }
	            }
            }
        }
Ejemplo n.º 3
0
        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));
        }