在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安装使用
- 在Visual Studio.NET中使用自定义插件最大化您的生产力(三)Custom Add-Ins Help You Maximize the Productivity of Visual Studio .NET
- .NET中使用log4net
- 学习在vb.net中使用excel.application
- 在ASP.NET中使用Excel提供的类读取excel数据
- 2013 不能使用Microsoft Office Word Add-in For MediaWiki
- 简单使用log4net
- 使用ASP.NET的GridView导出/儲存資料至Excel,Word,Txt檔,Powerpoint
- WIN7下VC6.0无法使用打开功能(Unable to register this add-in because its DLLRegisterServer return an error)
- .net下使用Common.Logging和log4net
- 如何使用 Visual C# .NET 处理 Excel 事件
- [VB.NET]vb.net中使用treenodecollection的add 方法出错
- ASP.NET MVC 3 Beta: Built-in support for charts(MVC3 Razor中使用图表的最佳方案)
- vb.net开发中使用excel插件学习
- 编写VS.NET的Add-in帮助程序调试
- ASP.NET 中 NPOI & LinqToSql 使用模板 导出 Excel
- 如何使用 Visual C# 2005 或 Visual C# .NET 向 Excel 工作簿传输数据