设为首页 收藏本站
查看: 611|回复: 0

[经验分享] About Apache log4net

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-1 13:30:41 | 显示全部楼层 |阅读模式
  From: http://logging.apache.org/log4net/index.html
  
  
About Apache 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. We have kept the framework similar in spirit to the original log4j                      while taking advantage of new features in the .NET runtime.                     For more information on log4net see the features document.                 
  log4net is part of the Apache Logging Services                      project. The Logging Services project is intended to provide cross-language logging                      services for purposes of application debugging and auditing.                 

log4net Features
               DSC0000.gif
Overview
  log4net is a tool to help the programmer output log statements to a                      variety of output targets. In case of problems with an application,                      it is helpful to enable logging so that the problem can be located.                      With log4net it is possible to enable logging at runtime without                      modifying the application binary. The log4net package is designed so                      that log statements can remain in shipped code without incurring a                      high performance cost. It follows that the speed of logging (or                      rather not logging) is crucial.                 
  At the same time, log output can be so voluminous that it quickly becomes                      overwhelming. One of the distinctive features of log4net is the notion of                      hierarchical loggers. Using these loggers it is possible to selectively                      control which log statements are output at arbitrary granularity.                  
  log4net is designed with two distinct goals in mind: speed and flexibility                 

Features

  • Support for multiple frameworks
  • Output to multiple logging targets
  • Hierarchical logging architecture
  • XML Configuration
  • Dynamic Configuration
  • Logging Context
  • Proven architecture
  • Modular and extensible design
  • High performance with flexibility


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
Note: Due to the .NET frameworks support for backward compatibility                      log4net will run on future versions of the runtimes listed above.                              

Output to multiple logging targets
log4net ships with the following appenders (not on all frameworks):
                                 Type                                                              Descriptionlog4net.Appender.AdoNetAppender                                 Writes logging events to a database using either prepared statements or stored                                  procedures.                             log4net.Appender.AnsiColorTerminalAppender                                 Writes color highlighted logging events to a an ANSI terminal window.                             log4net.Appender.AspNetTraceAppender                                 Writes logging events to the ASP trace context. These can then be rendered at                                  the end of the ASP page or on the ASP trace page.                             log4net.Appender.ColoredConsoleAppender                                 Writes color highlighted logging events to the application's Windows Console.                             log4net.Appender.ConsoleAppender                                 Writes logging events to the application's Console. The events may go to either                                  the standard our stream or the standard error stream.                             log4net.Appender.EventLogAppender                                 Writes logging events to the Windows Event Log.                             log4net.Appender.FileAppender                                 Writes logging events to a file in the file system.                             log4net.Appender.LocalSyslogAppender                                 Writes logging events to the local syslog service (UNIX only).                             log4net.Appender.MemoryAppender                                 Stores logging events in an in memory buffer.                             log4net.Appender.NetSendAppender                                 Writes logging events to the Windows Messenger service. These messages are                                  displayed in a dialog on a users terminal.                             log4net.Appender.OutputDebugStringAppender                                 Writes logging events to the debugger. If the application has no                                  debugger, the system debugger displays the string. If the application has no                                  debugger and the system debugger is not active, the message is ignored.                             log4net.Appender.RemoteSyslogAppender                                 Writes logging events to a remote syslog service using UDP networking.                             log4net.Appender.RemotingAppender                                 Writes logging events to a remoting sink using .NET remoting.                             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.                             log4net.Appender.SmtpAppender                                 Sends logging events to an email address.                             log4net.Appender.TelnetAppender                                 Clients connect via Telnet to receive logging events.                             log4net.Appender.TraceAppender                                 Writes logging events to the .NET trace system.                             log4net.Appender.UdpAppender                                 Sends logging events as connectionless UDP datagrams to a remote host or a                                  multicast group using a UdpClient.                             

Hierarchical logging architecture
Hierarchical logging is an ideal fit with component based development.                      Each component has its own of logger. When individually tested, the                      properties of these loggers may be set as the developer requires.                      When combined with other components, the loggers inherit the properties                      determined by the integrator of the components. One can selectively elevate                      logging priorities on one component without affecting the other components.                      This is useful when you need a detailed trace from just a single component                      without crowding the trace file with messages from other components. All                      this can be done through configuration files; no code changes are required.                                          

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.                              

Dynamic Configuration
log4net can monitor its configuration file for changes and dynamically                     apply changes made by the configurator. The logging levels, appenders,                      layouts, and just about everything else can be adjusted at runtime.                      In many cases it is possible to diagnose application issues without                      terminating the process in question. This can a very valuable tool in                     investigating issues with deployed applications.                              

Logging Context
log4net can be used to collect logging context data in a way that is transparent                      to the developer at the point of logging. The GlobalContext and the                      ThreadContext allow the application to store contextual data that is                     attached to logging messages. For instance, in a web service,                      once the caller is authenticated the username of the caller could be                      stored in a ThreadContext property. This property would then be automatically                      logged as part of each subsequent logging message made from the same thread.                              

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.
  REF:
  Log4net GUI Configuration Tool   http://www.codeproject.com/KB/cs/Log4netEditor.aspx

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-93045-1-1.html 上篇帖子: Apache alias目录配置 下篇帖子: Unable to read TLD "META-INF/fmt.tld" from JAR file "file:/D:/…./.metadata/.plug
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表