Log4Net 不使用配置文件,如何在程序中动态设定?
代码如下:程序运行起来不行,AdoNetAppender adoAppender=new AdoNetAppender();
adoAppender.CommandText="INSERT INTO Log (Datetime,Thread,Log_Level,Logger,Message,UserName,Category) VALUES (:log_date, :thread, :log_level, :logger,:message,:username,:category)";
adoAppender.ConnectionString="data source=WZG;User ID=www;Password=123";
adoAppender.ConnectionType="System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
adoAppender.Name="testAdoAppender";
adoAppender.BufferSize=0;
AdoNetAppenderParameter para;
PatternLayout pattern=new PatternLayout();
RawLayoutConverter rawConverter=new RawLayoutConverter();
IRawLayout irawLayout= rawConverter.ConvertFrom(pattern as ILayout)
as IRawLayout;
para=new AdoNetAppenderParameter();
para.ParameterName=":log_date";
para.DbType=System.Data.DbType.String;
para.Layout=irawLayout;
adoAppender.AddParameter(para);
log4net.Config.BasicConfigurator.Configure(adoAppender);
哪位大侠遇到过这种情况,望指点指点!! --------------------编程问答-------------------- 没用过,关注下。 --------------------编程问答-------------------- 没有接触过。帮顶。 --------------------编程问答-------------------- 看到上面只能帮顶 --------------------编程问答-------------------- 通过配置文件使用过,程序中实现不了解,那楼主还要看log4net相关接口..
用配置文件多方便,不然改变日志级别多麻烦..
--------------------编程问答-------------------- http://www.cnblogs.com/dragon/archive/2005/03/24/124254.html --------------------编程问答-------------------- Log4Net是可以完全在程序中配置的
补充:.NET技术 , C#