use*_*405 4 log4net dynamics-crm-2011
我试图在CRM 2011插件中记录一些信息.我不知道如何配置log4net.我应该在哪里放置log4net配置文件以及如何从插件中引用?谢谢!
假设您要将插件注册到数据库,您有几个选择:
将log4net配置文件嵌入到插件程序集中并从流中配置log4net(如下所示,插件基类中希望记录的其他插件可以继承)
namespace TestPlugins
{
public abstract class BaseLoggingPlugin
{
protected static readonly ILog _log = LogManager.GetLogger(typeof(BaseLoggingPlugin));
static BaseLoggingPlugin()
{
using(var config = Assembly.GetExecutingAssembly().GetManifestResourceStream("TestPlugins.log4net.config"))
{
XmlConfigurator.Configure(config);
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
2528 次 |
最近记录: |