• 大小: 1.4MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-20
  • 语言: C#
  • 标签: Log4Net  VB.net和C#  

资源简介

Log4Net的Demo,配置文件从网上找到,个人认为使用起来简单有效。本配置文件只实现了文本方式的日志输出(按不同的日志等级输出到不同的目录,并按照日期创建日志。配置文件中设置日志保留10天)。如果需要其他方式的输出,本Demo没法帮到你。Demo有Vb.net和C#两个例子。

资源截图

代码片段和文件信息

//INSTANT C# NOTE: Formerly VB project-level imports:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.xml.Linq;

using log4net;

namespace Log4NetDemo
{
public partial class Form1
{

public Form1()
{
InitializeComponent();
}

private void Button1_Click(object sender EventArgs e)
{
Module1.Logger.Warn(“这是一个警告日志“);
Module1.Logger.Info(“这是一个Info日志“);
Module1.Logger.Debug(“这是一个Debug日志“);
Module1.Logger.Error(“这是一个错误日志“);
Module1.Logger.Fatal(“这是一个致命的错误日志“);
Form2.DefaultInstance.Show();
}


private static Form1 _DefaultInstance;
public static Form1 DefaultInstance
{
get
{
if (_DefaultInstance == null || _DefaultInstance.IsDisposed)
_DefaultInstance = new Form1();

return _DefaultInstance;
}
}
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     20480  2019-07-01 09:18  Log4NetDemo\Log4NetDemo\.vs\Log4NetDemo\v16\.suo

     文件         74  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log\Debug\20190701.log

     文件         73  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log\Error\20190701.log

     文件         79  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log\Fatal\20190701.log

     文件         73  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log\Info\20190701.log

     文件         73  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log\Warn\20190701.log

     文件       4499  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\log4net.config

     文件     276480  2017-03-08 19:25  Log4NetDemo\Log4NetDemo\bin\Debug\log4net.dll

     文件      13824  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log4NetDemo.exe

     文件      44544  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log4NetDemo.pdb

     文件        679  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\bin\Debug\Log4NetDemo.xml

     文件       1727  2019-07-01 09:18  Log4NetDemo\Log4NetDemo\Form1.Designer.vb

     文件       5817  2019-07-01 09:18  Log4NetDemo\Log4NetDemo\Form1.resx

     文件        598  2019-07-01 09:18  Log4NetDemo\Log4NetDemo\Form1.vb

     文件       4499  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\log4net.config

     文件     276480  2017-03-08 19:25  Log4NetDemo\Log4NetDemo\log4net.dll

     文件       1127  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\Log4NetDemo.sln

     文件       5224  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\Log4NetDemo.vbproj

     文件        231  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\Log4NetDemo.vbproj.user

     文件       1493  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Application.Designer.vb

     文件        510  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Application.myapp

     文件       1127  2019-07-01 08:54  Log4NetDemo\Log4NetDemo\My Project\AssemblyInfo.vb

     文件       2778  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Resources.Designer.vb

     文件       5612  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Resources.resx

     文件       2985  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Settings.Designer.vb

     文件        279  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\My Project\Settings.settings

     文件        966  2019-07-01 08:51  Log4NetDemo\Log4NetDemo\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6850  2019-07-01 08:58  Log4NetDemo\Log4NetDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件      13824  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\obj\Debug\Log4NetDemo.exe

     文件        180  2019-07-01 08:59  Log4NetDemo\Log4NetDemo\obj\Debug\Log4NetDemo.Form1.resources

............此处省略164个文件信息

评论

共有 条评论