gpt4 book ai didi

c# - typeof(_Default) 使用 Log4Net 时出错

转载 作者:太空宇宙 更新时间:2023-11-03 23:30:49 25 4
gpt4 key购买 nike

我正在做一个 C# MVC 项目,我需要一些听觉,所以我在项目上安装了 Log4net,并按照这里的教程进行操作

http://kaizen-force.com/2015/03/24/log4net-c-visual-studio-2013/

当我使用这行代码时

private static readonly ILog log = LogManager.GetLogger(typeof(_Default));

我收到这个错误

Error   2   The type or namespace name '_Default' could not be found (are you missing a using directive or an assembly reference?)  D:\PC\Visual Studio 2013\Projects\SSMS-2.0.1\SSMS-2.0.1\Controllers\UsuariosXesController.cs    20  72  SSMS_2._0._1

我错过了什么吗?我怎样才能做到这一点?

最佳答案

You'll note在教程中,他创建了一个名为 _Default 的类,而这个 log 字段是该类中的静态字段。如果您有一个不同名称的类,则需要在 typeof() 中更改名称。

private static readonly ILog log = LogManager.GetLogger(typeof(UsuariosXesController));

关于c# - typeof(_Default) 使用 Log4Net 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32275845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com