<?xml version="1.0"?>
<doc>
<assembly>
<name>log4net</name>
</assembly>
<members>
<member name="T:log4net.Appender.AdoNetAppender">
<summary>
Appender that logs to a database.
</summary>
<remarks>
<para>
<see cref="T:log4net.Appender.AdoNetAppender"/> appends logging events to a table within a
database. The appender can be configured to specify the connection
string by setting the <see cref="P:log4net.Appender.AdoNetAppender.ConnectionString"/> property.
The connection type (provider) can be specified by setting the <see cref="P:log4net.Appender.AdoNetAppender.ConnectionType"/>
property. For more information on database connection strings for
your specific database see <a href="http://www.connectionstrings.com/">http://www.connectionstrings.com/</a>.
</para>
<para>
Records are written into the database either using a prepared
statement or a stored procedure. The <see cref="P:log4net.Appender.AdoNetAppender.CommandType"/> property
is set to <see cref="F:System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>) to specify a prepared statement
or to <see cref="F:System.Data.CommandType.StoredProcedure"/> (<c>System.Data.CommandType.StoredProcedure</c>) to specify a stored
procedure.
</para>
<para>
The prepared statement text or the name of the stored procedure
must be set in the <see cref="P:log4net.Appender.AdoNetAppender.CommandText"/> property.
</para>
<para>
The prepared statement or stored procedure can take a number
of parameters. Parameters are added using the <see cref="M:log4net.Appender.AdoNetAppender.AddParameter(log4net.Appender.AdoNetAppenderParameter)"/>
method. This adds a single <see cref="T:log4net.Appender.AdoNetAppenderParameter"/> to the
ordered list of parameters. The <see cref="T:log4net.Appender.AdoNetAppenderParameter"/>
type may be subclassed if required to provide database specific
functionality. The <see cref="T:log4net.Appender.AdoNetAppenderParameter"/> specifies
the parameter name, database type, size, and how the value should
be generated using a <see cref="T:log4net.Layout.ILayout"/>.
</para>
</remarks>
<example>
An example of a SQL Server table that could be logged to:
<code lang="SQL">
CREATE TABLE [dbo].[Log] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[Date] [datetime] NOT NULL ,
[Thread] [varchar] (255) NOT NULL ,
[Level] [varchar] (20) NOT NULL ,
[Logger] [varchar] (255) NOT NULL ,
[Message] [varchar] (4000) NOT NULL
) ON [PRIMARY]
</code>
</example>
<example>
An example configuration to log to the above table:
<code lang="XML" escaped="true">
<appender name="AdoNetAppender_SqlServer" type="log4net.Appender.AdoNetAppender">
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<connectionString value="data source=SQLSVR;initial catalog=test_log4net;integrated security=false;persist security info=True;User ID=sa;Password=sa"/>
<commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)"/>
<parameter>
<parameterName value="@log_date"/>
<dbType value="DateTime"/>
<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}"/>
</parameter>
<parameter>
<parameterName value="@thread"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout" value="%thread"/>
</parameter>
<parameter>
<parameterName value="@log_level"/>
<dbType value="String"/>
<size value="50"/>
<layout type="log4net.Layout.PatternLayout" value="%level"/>
</parameter>
<parameter>
<parameterName value="@logger"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout" value="%logger"/>
</parameter>
<parameter>
<parameterName value="@message"/>
<dbType value="String"/>
<size value="4000"/>
<layout type="log4net.Layout.PatternLayout" value="%message"/>
</parameter>
</appender>
</code>
</example>
<author>Julian Biddle</author>
<author>Nicko Cadell</author>
<author>Gert Driesen</author>
<author>Lance Nehring</author>
</member>
<member name="T:log4net.Appender.BufferingAppenderSkeleton">
<summary>
Abstract base class implementation of <see cref="T:log4net.Appender.IAppender"/> that
buffers events in a fixed size buffer.
</summary>
<remarks>
<para>
This base class should be used by appenders that need to buffer a
number of events before logging them. For example the <see cref="T:log4net.Appender.AdoNetAppender"/>
buffers events and then submits the entire contents of the buffer to
the underlying database in one go.
</para>
<para>
Subclasses should override the <see cref="M:log4net.Appender.BufferingAppenderSkeleton.SendBuffer(log4net.Core.LoggingEvent[])"/>
method to deliver the buffered events.
</para>
<para>The BufferingAppenderSkeleton maintains a fixed size cyclic
buffer of events. The size of the buffer is set using
the <see cref="P:log4net.Appender.BufferingAppenderSkeleton.BufferSize"/> property.
</para>
<para>A <see cref="T:log4net.Core.ITriggeringEventEvaluator"/> is used to inspect
each event as it arrives in the appender. If the <see cref="P:log4net.Appender.BufferingAppenderSkeleton.Evaluator"/>
triggers, then the current buffer is sent immediately
(see <see cref="M:log4net.Appender.BufferingAppenderSkeleton.SendBuffer(log4net.Core.LoggingEvent[])"/>). Otherwise the event
is stored in the buffer. For example, an evaluator can be used to
deliver the events immediately when an ERROR event arrives.
</para>
<para>
The buffering appender can be configured in a <see cref="P:log4net.Appender.BufferingAppenderSkeleton.Lossy"/> mode.
By default the appender is NOT lossy. When the buffer is full all
the buffered events are sent with <see cref="M:log4net.Appender.BufferingAppenderSkeleton.SendBuffer(log4net.Core.LoggingEvent[])"/>.
If the <see cref="P:log4net.Appender.BufferingAppenderSkeleton.Lossy"/> property is set to <c>true</c> then the
buffer will not be sent when it is full, and new events arriving
in the appender will overwrite the oldest event in the buffer.
In lossy mode the buffer will only be sent when the <see cref="P:log4net.Appender.BufferingAppenderSkeleton.Evaluator"/>
triggers. This can be useful
没有合适的资源?快使用搜索试试~ 我知道了~
应用Log4net库记录日志信息的C#实例程序Ky_Log4N.rar
共31个文件
cs:8个
config:5个
log:4个
需积分: 47 8 下载量 136 浏览量
2020-09-09
15:34:22
上传
评论
收藏 413KB RAR 举报
温馨提示
应用Log4net库记录日志信息的C#实例程序。1. 首先从apache网站下载log4net, http://logging.apache.org/log4net/download_log4net.cgi 。2、创建一个新的log4net的配置文件Log4Net.config。3、新增一个LogHelper。4、初始化log4net。5、在需要写日志的地方调用LogHelper的相关函数写日志。
资源推荐
资源详情
资源评论
收起资源包目录
Ky_Log4N.rar (31个子文件)
Ky_Log4N
Ky_Log4N
Form1.Designer.cs 4KB
Program.cs 2KB
Lib
log4net.dll 244KB
log4net.xml 1.23MB
LogHelper.cs 2KB
bin
Debug
Ky_Log4N.pdb 28KB
log4net.config 5KB
log4net.dll 244KB
log4net.xml 1.23MB
Ky_Log4N.vshost.exe.config 187B
Ky_Log4N.vshost.exe.manifest 490B
Ky_Log4N.exe 13KB
Ky_Log4N.exe.config 187B
logs
2020-09-09 app
Info.log 336B
Debug.log 0B
Warn.log 0B
Error.log 977B
Ky_Log4N.vshost.exe 24KB
Form1.cs 2KB
log4net.config 5KB
Form1.resx 6KB
App.config 187B
log.cs 617B
Ky_Log4N.csproj 4KB
Properties
AssemblyInfo.cs 1KB
Settings.Designer.cs 1KB
Resources.resx 5KB
Settings.settings 249B
Resources.Designer.cs 3KB
Ky_Log4N.sln 993B
Ky_Log4N.v12.suo 42KB
共 31 条
- 1
资源评论
dalong10
- 粉丝: 140
- 资源: 33
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功