16
Albert Kuo 1

Logging Services for .net - log4net

Embed Size (px)

Citation preview

Page 1: Logging Services for .net - log4net

Albert Kuo

1

Page 2: Logging Services for .net - log4net

Introduction Features Configuration

◦ Import log4net DLL◦ Create config.xml◦ Set Log4Net.xml file path◦ Insert log requests into the application code

Reference

2

Page 3: Logging Services for .net - log4net

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

Page 4: Logging Services for .net - log4net

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

Page 5: Logging Services for .net - log4net

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

Page 6: Logging Services for .net - log4net

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

Page 7: Logging Services for .net - log4net

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

Page 8: Logging Services for .net - log4net

8

Page 9: Logging Services for .net - log4net

9

Page 10: Logging Services for .net - log4net

10

Concerning conversationPattern, please check: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html

Page 11: Logging Services for .net - log4net

11

Page 12: Logging Services for .net - log4net

12

Page 13: Logging Services for .net - log4net

13

Log level

Page 14: Logging Services for .net - log4net

14

ConsoleAppender

Page 15: Logging Services for .net - log4net

15

RollingFileAppender

Page 16: Logging Services for .net - log4net

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