在Excel Add-in中使用log4NET
2012-02-14 16:23
288 查看
在Excel Add-in中没有办法设定配置文件。所以我们需要在程序中设定Log4NET的配置。
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Office.Core; using Microsoft.Office.Tools.Excel; using log4net; using System.Diagnostics; using System.IO; namespace ExcelAddIn4 { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { try { log4net.Config.BasicConfigurator.Configure(new log4net.Appender.FileAppender( new log4net.Layout.PatternLayout("%d [%t]%-5p %c [%x] - %m%n"), @"C:\******\testfile.log")); s.Close(); ILog log = LogManager.GetLogger(typeof(ExcelAddIn4.Globals)); log.Error("dddddddd"); } catch (Exception ex) { Debug.Print(ex.Message); } } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
相关文章推荐
- 在Excel Add-in中使用log4NET
- [转贴]使用VS.NET 2003 快速开发MS Office Add-In
- 使用Visual Studio2010 Profiler评测.Net Office add-in
- ALM插件Excel Add-In安装使用
- 使用ADO.net将数据导出到Excel并提供下载
- ASP.NET使用NPOI类库导出Excel
- 在ASP.NET MVC 4 on Mono中使用OracleClient in CentOS 6.x的问题记录
- WinForm中如何使用Log4net
- ASP.NET使用GridView导出Excel实现方法
- .net服务器没有COM+组件情况下使用NOPI和MyXls导入导出excel
- C#.NET常见问题(FAQ)-如何使用DataGridView跟Excel数据交互
- 在.Net中使用log4Net
- 在Visual Studio.NET中使用自定义插件最大化您的生产力(一)Custom Add-Ins Help You Maximize the Productivity of Visual Studio .NET
- Add-in and Automation Development in VB.NET 2003 (6-7)
- [ASP.NET] 使用NPOI產生EXCEL
- csharp: Export DataTable to Excel using OpenXml 2.5 in asp.net
- 解决微服务网关Ocelot使用AddStoreOcelotConfigurationInConsul后请求404问题
- Add Html/javascript Event In ASP.NET(C#)
- 使用VSIUAL C#.NET操作Excel -把DataTable中的数据写入Excel
- asp.net 解决使用OLEDB导入excel数据时同时包含文本和数字的列无法正常读取情况