Common.Logging.Log4Net1213
Routes log events to Common.Logging infrastructure.
To route all events logged using log4net to Common.Logging, you need to configure this appender as shown below:
<log4net>
<appender name="CommonLoggingAppender"
type="Common.Logging.Log4Net.CommonLoggingAppender, Common.Logging.Log4Net129">
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%level - %class.%method: %message" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="CommonLoggingAppender" />
</root>
</log4net>
Erich Eichinger
Gets the closest level supported by Common.Logging of the given log4net level
Sends the given log event to Common.Logging
Get or set the layout for this appender
Wrapper class that prevents exceptions from being rendered in the message
A global context for logger variables
Sets the value of a new or existing variable within the global context
The key of the variable that is to be added
The value to add
Gets the value of a variable within the global context
The key of the variable to get
The value or null if not found
Checks if a variable is set within the global context
The key of the variable to check for
True if the variable is set
Removes a variable from the global context by key
The key of the variable to remove
Clears the global context variables
Concrete implementation of interface specific to log4net 1.2.9-1.2.11.
Log4net is capable of outputting extended debug information about where the current
message was generated: class name, method name, file, line, etc. Log4net assumes that the location
information should be gathered relative to where Debug() was called.
When using Common.Logging, Debug() is called in Common.Logging.Log4Net.Log4NetLogger. This means that
the location information will indicate that Common.Logging.Log4Net.Log4NetLogger always made
the call to Debug(). We need to know where Common.Logging.ILog.Debug()
was called. To do this we need to use the log4net.ILog.Logger.Log method and pass in a Type telling
log4net where in the stack to begin looking for location information.
Gilles Bayon
Erich Eichinger
Constructor
Actually sends the message to the underlying log system.
the level of this log event.
the message to log
the exception to log (may be null)
Maps to log4net's
Returns the global context for variables
Returns the thread-specific context for variables
Concrete subclass of ILoggerFactoryAdapter specific to log4net 1.2.9-1.2.11.
The following configuration property values may be configured:
- configType: INLINE|FILE|FILE-WATCH|EXTERNAL
- configFile: log4net configuration file path in case of FILE or FILE-WATCH
The configType values have the following implications:
- INLINE: simply calls XmlConfigurator.Configure()
- FILE: calls XmlConfigurator.Configure(System.IO.FileInfo) using configFile.
- FILE-WATCH: calls XmlConfigurator.ConfigureAndWatch(System.IO.FileInfo) using configFile.
- EXTERNAL: does nothing and expects log4net to be configured elsewhere.
- <any>: calls BasicConfigurator.Configure()
The following snippet shows an example of how to configure log4net with Common.Logging:
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging"
type="Common.Logging.ConfigurationSectionHandler, Common.Logging"
requirePermission="false" />
</sectionGroup>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler"
requirePermission="false" />
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net129">
<arg key="level" value="ALL" />
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net debug="false">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender, log4net">
<param name="File" value="./Web.log" />
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="1" />
<param name="MaximumFileSize" value="1GB" />
<param name="RollingStyle" value="Date" />
<param name="StaticLogFileName" value="false" />
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p: %m" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="TraceAppender" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
</configuration>
Gilles Bayon
Erich Eichinger
Constructor
configuration properties, see for more.
Constructor for binary backwards compatibility with non-portableversions
The properties.
Constructor accepting configuration properties and an arbitrary
instance.
configuration properties, see for more.
a log4net runtime adapter
Create a ILog instance by name
Abstract interface to the underlying log4net runtime
Calls
Calls
Calls
Calls
Calls
A global context for logger variables
Sets the value of a new or existing variable within the global context
The key of the variable that is to be added
The value to add
Gets the value of a variable within the global context
The key of the variable to get
The value or null if not found
Checks if a variable is set within the global context
The key of the variable to check for
True if the variable is set
Removes a variable from the global context by key
The key of the variable to remove
Clears the global context variables