写日志文件

//根据当前程序集的路径,加载xml文件
            XDocument xdoc = XDocument.Load(@"d:\documents\visual studio 2010\Projects\Demo\第二题\MyLog4NetMain\log4net.xml");
            //获取xml根节点的值
            string dllPath = xdoc.Root.Attribute("path").Value;
            string dllType = xdoc.Root.Attribute("type").Value;
            //根据该方法所在的程序集路径 加载程序集
            Assembly asm = Assembly.LoadFile(dllPath);
            // 根据类全名(命名空间+类名) 获得该类的类型
            Type type = asm.GetType(dllType);
            //根据类创建该类对象,返回为object类型 
            ILog log = Activator.CreateInstance(type) as ILog;
            log.Debug("程序启动完成");
原文地址:https://www.cnblogs.com/hejinyang/p/3031050.html