master
editor 1 month ago
commit 981f0b54f0

@ -0,0 +1,36 @@
LOG4NET控件应用入门实例源码
一、源码描述
环境VS2022 
二、功能介绍
Log4net是基于.net开发的一款非常著名的记录日志开源组件记录日志的功能非常强大。它可以将日志分不同的等级比不同的样式将日志输出到不同的媒介。
该源码一个log4net使用入门的Asp.net实例源码默认使用的是文本记录方式bnetLog.txt为日志记录文件日志大小限制为5M具体的配置在web.config中进行设置。
三、注意事项
ctrl+F5运行即可。
作者: iyond
如需获得该源码的视频、更新等更多资料请访问: https://www.51aspx.com/Code/log4netQuikStart
------------------------------------------------------------------------------------------------
源码服务专家
官网: https://www.51aspx.com
讨论圈: https://club.51aspx.com/
平台声明:
1.51Aspx平台上提供下载的资源为免费、共享、商业三类源码,其中免费和共享源码仅供个人学习和研究使用,商业源码请在相应的授权许可条件下使用;
2.51Aspx平台对提供下载的软件及其它资源不拥有任何权利,其版权归属源码合法拥有者所有;
3.著作权人发现本网站载有侵害其合法权益的内容或作品,请与我们联系( 登录官网与客服反馈或发送邮件到support@51Aspx.com
4.51Aspx平台不保证提供的下载资源的准确性、安全性和完整性;
友情提示:
一般数据库文件默认在 DB_51Aspx 文件夹下
默认账号密码一般均为51Aspx
关于源码使用常见问题及解决方案,请参阅: https://www.51aspx.com/Help

@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Log4NetTest._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>log4net<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>Դ<EFBFBD><D4B4></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="<22><><EFBFBD><EFBFBD>log4net<65><74>־" Height="56px" Width="147px" /><br />
<br />
<asp:Label ID="lbMsg" runat="server" />
&nbsp;</div>

@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using log4net;
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>www.51aspx.com(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
namespace Log4NetTest
{

@ -0,0 +1,15 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Log4NetTest {
/// <summary>
/// _Default class.

@ -0,0 +1 @@
<%@ Application Codebehind="Global.asax.cs" Inherits="Log4NetTest.Global" Language="C#" %>

@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace Log4NetTest
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5CEDCE00-5AAB-4D6D-9943-E0898678CDC2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Log4NetTest</RootNamespace>
<AssemblyName>Log4NetTest</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

@ -0,0 +1,15 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Log4NetTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Iyond")]
[assembly: AssemblyProduct("Log4NetTest")]
[assembly: AssemblyCopyright("Copyright © Iyond 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only

@ -0,0 +1,15 @@
<?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.

@ -0,0 +1 @@
{"RootPath":"C:\\Users\\coder\\Desktop\\2024Code\\5\\20240529\\update\\log4netQuikStart\\Log4NetTest","ProjectFileName":"Log4NetTest.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Default.aspx.cs"},{"SourceFile":"Default.aspx.designer.cs"},{"SourceFile":"Global.asax.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.0.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Users\\coder\\Desktop\\2024Code\\5\\20240529\\update\\log4netQuikStart\\Lic\\log4net.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Configuration\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Configuration.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.Data\\v4.0_4.0.0.0__b77a5c561934e089\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System\\v4.0_4.0.0.0__b77a5c561934e089\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.EnterpriseServices\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.EnterpriseServices.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\System.Web\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.Mobile\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Web.Mobile.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Web.Services\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Web.Services.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Windows\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Xml\\v4.0_4.0.0.0__b77a5c561934e089\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\coder\\Desktop\\2024Code\\5\\20240529\\update\\log4netQuikStart\\Log4NetTest\\bin\\Log4NetTest.dll","OutputItemRelativePath":"Log4NetTest.dll"},{"OutputItemFullPath":"C:\\Users\\coder\\Desktop\\2024Code\\5\\20240529\\update\\log4netQuikStart\\Log4NetTest\\bin\\Log4NetTest.pdb","OutputItemRelativePath":"Log4NetTest.pdb"}],"CopyToOutputEntries":[]}

@ -0,0 +1,15 @@
2007-06-28 10:38:09,500 [3344] INFO iyondtest [(null)] -
2007-06-28 10:38:13,546 [3344] INFO iyondtest [(null)] -
2007-06-28 10:39:14,484 [3344] INFO iyondtest [(null)] -
2007-06-28 10:41:04,718 [7] INFO iyondtest [(null)] -
2007-06-28 10:42:02,625 [7] INFO iyondtest [(null)] -
2007-06-28 10:42:24,921 [7] INFO iyondtest [(null)] -
2007-06-28 10:43:17,703 [7] INFO iyondtest [(null)] -
2007-07-02 09:27:11,687 [4] INFO iyondtest [(null)] -
2007-07-02 09:27:27,781 [4] INFO iyondtest [(null)] -
2007-07-02 09:28:08,750 [4] INFO iyondtest [(null)] -
2007-07-02 09:31:11,546 [4] INFO iyondtest [(null)] -
2007-07-02 09:33:29,921 [4] INFO iyondtest [(null)] -
2007-07-02 09:33:51,328 [4] INFO iyondtest [(null)] -
2007-07-02 09:36:18,796 [4] INFO iyondtest [(null)] -
2007-07-02 09:37:35,796 [4] INFO iyondtest [(null)] -

@ -0,0 +1,15 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Log4NetTest._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>log4net<65>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>Դ<EFBFBD><D4B4></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="<22><><EFBFBD><EFBFBD>log4net<65><74>־" Height="56px" Width="147px" /><br />
<br />
<asp:Label ID="lbMsg" runat="server" />
&nbsp;</div>

@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using log4net;
//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>www.51aspx.com(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
namespace Log4NetTest
{

@ -0,0 +1,15 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Log4NetTest {
/// <summary>
/// _Default class.

@ -0,0 +1 @@
<%@ Application Codebehind="Global.asax.cs" Inherits="Log4NetTest.Global" Language="C#" %>

@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace Log4NetTest
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{

@ -0,0 +1,15 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{5CEDCE00-5AAB-4D6D-9943-E0898678CDC2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Log4NetTest</RootNamespace>
<AssemblyName>Log4NetTest</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>

@ -0,0 +1,15 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Log4NetTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Iyond")]
[assembly: AssemblyProduct("Log4NetTest")]
[assembly: AssemblyCopyright("Copyright © Iyond 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<appSettings/>
<connectionStrings/>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.8" />
</system.Web>
-->

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<appSettings/>
<connectionStrings/>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.8" />
</system.Web>
-->

@ -0,0 +1,15 @@
<?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.

@ -0,0 +1,13 @@
2007-06-28 10:43:17,703 [7] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:27:11,687 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:27:27,781 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:28:08,750 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:31:11,546 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:33:29,921 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:33:51,328 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:36:18,796 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:37:35,796 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:37:37,328 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:37:39,406 [4] INFO iyondtest [(null)] - (null) (null) (null)
2007-07-02 09:37:40,406 [4] INFO iyondtest [(null)] - (null) (null) (null)
2024-05-28 17:36:40,102 [5] INFO iyondtest|-51aspx.com [(null)] - (null) (null) (null) Hello World

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

@ -0,0 +1,10 @@
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\bin\Log4NetTest.dll.config
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\bin\Log4NetTest.dll
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\bin\Log4NetTest.pdb
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\bin\log4net.dll
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\bin\log4net.xml
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\obj\Debug\Log4NetTest.csproj.AssemblyReference.cache
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\obj\Debug\Log4NetTest.csproj.CoreCompileInputs.cache
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\obj\Debug\Log4NetTest.csproj.CopyComplete
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\obj\Debug\Log4NetTest.dll
C:\Users\coder\Desktop\2024Code\5\20240529\update\log4netQuikStart\Log4NetTest\obj\Debug\Log4NetTest.pdb

@ -0,0 +1,7 @@
bin\Log4NetTest.dll
bin\Log4NetTest.pdb
bin\log4net.dll
obj\Debug\ResolveAssemblyReference.cache
obj\Debug\Log4NetTest.dll
obj\Debug\Log4NetTest.pdb
bin\log4net.xml
Loading…
Cancel
Save