1
#region Copyright & License
3
// Copyright 2001-2005 The Apache Software Foundation
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
9
// http://www.apache.org/licenses/LICENSE-2.0
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
26
namespace log4net.Layout
29
/// A very simple layout
33
/// SimpleLayout consists of the level of the log statement,
34
/// followed by " - " and then the log message itself. For example,
36
/// DEBUG - Hello world
40
/// <author>Nicko Cadell</author>
41
/// <author>Gert Driesen</author>
42
public class SimpleLayout : LayoutSkeleton
47
/// Constructs a SimpleLayout
51
IgnoresException = true;
56
#region Implementation of IOptionHandler
59
/// Initialize layout options
63
/// This is part of the <see cref="IOptionHandler"/> delayed object
64
/// activation scheme. The <see cref="ActivateOptions"/> method must
65
/// be called on this object after the configuration properties have
66
/// been set. Until <see cref="ActivateOptions"/> is called this
67
/// object is in an undefined state and must not be used.
70
/// If any of the configuration properties are modified then
71
/// <see cref="ActivateOptions"/> must be called again.
74
override public void ActivateOptions()
81
#region Override implementation of LayoutSkeleton
84
/// Produces a simple formatted output.
86
/// <param name="loggingEvent">the event being logged</param>
87
/// <param name="writer">The TextWriter to write the formatted event to</param>
90
/// Formats the event as the level of the even,
91
/// followed by " - " and then the log message itself. The
92
/// output is terminated by a newline.
95
override public void Format(TextWriter writer, LoggingEvent loggingEvent)
97
if (loggingEvent == null)
99
throw new ArgumentNullException("loggingEvent");
102
writer.Write(loggingEvent.Level.DisplayName);
104
loggingEvent.WriteRenderedMessage(writer);