logging services for .net - log4net
TRANSCRIPT
Albert Kuo
1
Introduction Features Configuration
◦ Import log4net DLL◦ Create config.xml◦ Set Log4Net.xml file path◦ Insert log requests into the application code
Reference
2
log4net is a tool to help the programmer output log statements to a variety of output targets. log4net is a port of the excellent log4j framework to the .NET runtime.
http://logging.apache.org/log4net/index.html
3
Support for multiple frameworks◦ log4net runs on all ECMA CLI 1.0 compatible
runtimes. log4net has specific builds for the following frameworks: Microsoft .NET Framework 1.0 (1.0.3705) Microsoft .NET Framework 1.1 (1.1.4322) Microsoft .NET Framework 2.0 (2.0.50727) Microsoft .NET Compact Framework 1.0 Mono 1.0 Mono 2.0 Microsoft Shared Source CLI 1.0 CLI 1.0 Compatible
4
Output to multiple logging targets◦ log4net.Appender.AdoNetAppender
Writes logging events to a database using either prepared statements or stored procedures.
◦ log4net.Appender.ConsoleAppender Writes logging events to the application's Console.
◦ log4net.Appender.RollingFileAppender Writes logging events to a file in the file system. The
RollingFileAppender can be configured to log to multiple files based upon date or file size constraints.
For more information about appenders, please check: http://logging.apache.org/log4net/release/features.html
5
XML Configuration◦ log4net is configured using an XML configuration
file. The configuration information can be embedded within other XML configuration files (such as the application's .config file) or in a separate file.
◦ The configuration is easily readable and updateable while retaining the flexibility to express all configurations. Alternatively log4net can be configured programmatically.
6
Proven architecture◦ log4net is based on the highly successful log4j
logging library, in development since 1996. This popular and proven architecture has so far been ported to 12 languages.
7
8
9
10
Concerning conversationPattern, please check: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html
11
12
13
Log level
14
ConsoleAppender
15
RollingFileAppender
Official site:◦ http://logging.apache.org/log4net/index.html
Log4net download url: ◦ http://logging.apache.org/log4net/download.html
Using log4net:◦ http://ondotnet.com/pub/a/dotnet/2003/06/16/
log4net.html
16