Extaspnet application Techniques (eight)

Source: Internet
Author: User

Objective

To practice the project-driven extaspnet development process, I recently started another Open source project-Appbox.

The Appbox project uses extaspnet as the foreground presentation layer, subsonic as the ORM layer, SqlServer2005 as the database, in the asp.net2.0 based on the implementation of an enterprise integrated management system necessary for the basic components.

Including user management, menu management, rights Management, organizational structure management, and other parts, although Appbox is not for the end user, but can be used as a developer to build a Web site framework, while the project encountered in the control will be prioritized in the extaspnet implementation.

Because Log4net is used as a logging component in Appbox, this article shares the Log4net configuration and usage.

Log4net Configuration

1. First download the latest log4net v1.2.10 to http://logging.apache.org/.

2. Create DATABASE tables

01.CREATE TABLE [dbo].[Log] (
02.    [Id] [int] IDENTITY (1, 1) NOT NULL,
03.    [Date] [datetime] NOT NULL,
04.    [Thread] [varchar] (255) NOT NULL,
05.    [Level] [varchar] (50) NOT NULL,
06.    [Logger] [varchar] (255) NOT NULL,
07.    [Message] [varchar] (4000) NOT NULL,
08.    [Exception] [varchar] (2000) NULL
09.)

3. Add log4net.config files to the site root directory

01.<log4net>
<root>
<level value= "All"/>
<appender-ref ref= "Adonetappender"/>
<appender-ref ref= "Rollingfileappender"/>
</root>
<appender name= "Rollingfileappender" type= "log4net. Appender.rollingfileappender,log4net ">
<param name= "File" value= "Log\log.config"/>
<param name= "Appendtofile" value= "true"/>
<param name= "maxsizerollbackups" value= "/>"
<param name= "maximumFileSize" value= "5MB"/>
<param name= "Rollingstyle" value= "Size"/>
<param name= "Staticlogfilename" value= "true"/>
<layout type= "log4net. Layout.patternlayout,log4net ">
<param name= "Conversionpattern" value= "%d [%t]%-5p%c [%x]-%m%n"/>
</layout>
</appender>
<appender name= "Adonetappender" type= "log4net". Appender.adonetappender ">
<buffersize value= "0"/>
<connectiontype value= "System.Data.SqlClient.SqlConnection, System.Data, version=2.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "/>
<connectionstring value= "PASSWORD=SA; Persist Security info=true; User id=sa;initial catalog=appbox;data source=. " />
<commandtext value= "INSERT into X_log (datetime,thread,log_level,logger,message,exception) VALUES (@log_date, @ Thread, @log_level, @logger, @message, @exception) "/>
<parameter>
<parametername value= "@log_date"/>
<dbtype value= "DateTime"/>
<layout type= "log4net. Layout.rawtimestamplayout "/>
</parameter>
<parameter>
<parametername value= "@thread"/>
<dbtype value= "String"/>
<size value= "255"/>
<layout type= "log4net. Layout.patternlayout ">
<conversionpattern value= "%thread"/>
</layout>
</parameter>
<parameter>
<parametername value= "@log_level"/>
<dbtype value= "String"/>
<size value= "/>"
<layout type= "log4net. Layout.patternlayout ">
<conversionpattern value= "%level"/>
</layout>
</parameter>
<parameter>
<parametername value= "@logger"/>
<dbtype value= "String"/>
<size value= "255"/>
<layout type= "log4net. Layout.patternlayout ">
<conversionpattern value= "%logger"/>
</layout>
Wuyi </parameter>
<parameter>
<parametername value= "@message"/>
<dbtype value= "String"/>
<size value= "4000"/>
<layout type= "log4net. Layout.patternlayout ">
<conversionpattern value= "%message"/>
</layout>
</parameter>
<parameter>
<parametername value= "@exception"/>
<dbtype value= "String"/>
<size value= "/>"
<layout type= "log4net. Layout.exceptionlayout "/>
</parameter>
</appender>
67.</log4net>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.