如何在通用权限管理系统中集成log4net日志功能

8/3/2015来源:C#应用人气:1883

如何在通用权限管理系统中集成log4net日志功能

开发人员都知道,在系统运行中要记录各种日志,自己写一个日志功能,无论是在效率还是功能扩展上来说都不是很好,目前大多用的是第三方的日志系统,其中一个非常有名,用的最多的就是log4net。下面是关于这个组件的介绍

”Log4net是基于.net开发的一款非常著名的记录日志开源组件。最早是2001年7月由NeoWorksLimited启动的项目,基本的框架源, 于另外的一个非常著名的姐妹组件-log4j。现由Apache组织开发与维护。此日志架构是可灵活扩展,且通过配置文件来设置日志的属性及输出,不同修 改代码即可实现程序的灵活跟踪。可以将日志分不同的等级,通过不同的过滤条件,以不同的样式,将日志输出到不同的媒介。可以从http://logging.apache.org/log4net/l网站下载最新版本的Log4net源码。“

目前的log4net的最新版本是1.2.13.0

下面介绍下如何在通用权限管理系统的项目中使用这个组件实现将日志输出到文件和Oracle数据库中,重点介绍下日志输出到数据库中。

首先在官网下载最新源码,目前的源码可用VS2010打开。

QQQwwxxBBDPPliYtocnxlvryQNMcQQQwwxxBBDDDHEEDs2Jjy911IvIIYYYoghhhhiiCGGGGLHxgT5n4nA/hBDDDHEEEMMMcQQQzz5YmL2hxut+INvPBaunTlvFZvZff133c0vNoLcTYVPXny56dCMifE7H8QQQwyxHfFS/8D7+Q+QsQcMBoMnmotLSvw3HcCvXcR838D5voHvLg18zy/oPb+gBct2vb98t/eK3QtX7Fm4Ys8fV+5duGLX3EV/9fjjOnIYzuzZ9woHBofA7ujse4XUeZw4v/9BDDHEEIuM7+floeFOMBgMnpi+n5eHX7usA/efVu3906q9sz/cSA7Acwx9/QNg9zV1HidIvgpiiCGGWHyMhtrBYDB4Ihu/dhHJ8gekg0NP8wH3B6u/m/3hRnaOobu3D+y+njEBclQQQwwxxPbFaLAZDAaDJ7LxaxdhHBk1joyOjqLkK/kZ1x6dkVeev1lz5X79rUeaO8Wt5ZUaCrjZOQZdVy/YfT1jAuSoIIYYYojti9FAAxgMBk9k49cuorpBG64OHxoeP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