版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、using System;using System.Configuration;using System.Data;using log4net;using log4net.Config;using log4net.Appender;using log4net.Layout;using log4net.Util;namespace BizTalk.DAL.Log /*/ <summary> /&
2、#160;日志文件处理 / </summary> public sealed class LogUtil 变量#region 变量 /ConfigurationSettings.AppSettings
3、; protected static readonly log4net.ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static string logFilePat
4、h = string.Empty; /日志文件 错误文件 处理文件路径 private static string str_configfile = "E:Suzhou Project EDI代码
5、BizTalkSolution_suzhouBizTalk.suzhou.ConfigConfigDB.config" /日志文件的读写也由 xml文件读取 private static string logErrFilePath =System.Configuration.ConfigurationManager.AppSettings"
6、ErrFilePath" private static string logWarnFilePath = string.Empty; /日志文件路径 private static string logInfoFilePath
7、160;=System.Configuration.ConfigurationManager.AppSettings"logFilePath" #endregion /*/ <summary> / Ctr &
8、#160; / </summary> public LogUtil() 获得参数设置#region 获得参数设置 /*/ <summary>
9、0; / 根据配置文件里面参数名称读参数 / </summary> / <param name="ParameterName"></param> / <returns>
10、;</returns> public static string Get_Parameter(string ParameterName)
11、60; DataSet ds_config =BizTalk.DAL.Data.XmlObject.GetXml(str_configfile); string str_xml_proc = ds_config.TablesParameterName.Rows0"value".ToString();
12、60; return str_xml_proc; #endregion 写日志文件Method#region 写日志文件Method
13、; public static void WriteLog(string msg) string filePath = logFilePath;
14、60; FileAppender fa = GetFileAppender(filePath); log4net.Config.BasicConfigurator.Configure(fa); /写入日志
15、 logger.Debug(msg); /日志文件写入 public static void WriteLogInfo(string msg)
16、160; /string filePath = logInfoFilePath; string filePath = Get_Parameter("logFilePath").Trim();
17、; FileAppender fa = GetFileAppender(filePath); log4net.Config.BasicConfigurator.Configure(fa); &
18、#160; logger.Info(msg); public static void WriteLogWarn(string msg)
19、; string filePath = logWarnFilePath; FileAppender fa = GetFileAppender(filePath);
20、; log4net.Config.BasicConfigurator.Configure(fa); logger.Warn(msg); /错误文件写入
21、 public static void WriteLogErr(string msg) /string filePath = logErrFilePath;
22、60; string filePath = Get_Parameter("ErrFilePath").Trim(); FileAppender fa = GetFileAppender(filePath);
23、60;log4net.Config.BasicConfigurator.Configure(fa); logger.Error(msg); #endregion /*/
24、60;<summary> / 取得日志文件位置和样式 / </summary> / <param name="filePath">文件路径</param>
25、0; / <returns></returns> private static FileAppender GetFileAppender(string filePath)
26、 /日志文件布局 PatternLayout sLayout = new PatternLayout("%date %thread %-5level %logger %ndc - %message%newline"); &
27、#160; sLayout.Header = "Headerrn" sLayout.Footer = "Footerrn" /日志文件路径
28、160; string fileName = filePath + "" + System.DateTime.Now.ToString("yyyy-MM-dd")
29、60; + "" + System.DateTime.Now.ToString("yyyy-MM-dd") + "-Log.log" FileAppender fa = new FileAppender(sLayout,
30、60;fileName); return fa; 复制代码using System;using System.Collections.Generic;using System.Text;using System.Diagnostics;namespace
31、BizTalk.DAL.Log public class LogBase private static void Write(string msg, string category)
32、60; string path = string.Format("c:0.log", category); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path, true)&
33、#160; try
34、0; string lin = string.Format("2 0rn:1", category, msg, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
35、160; sw.WriteLine(lin); sw.Close();
36、60; catch (Exception e)
37、0; Console.WriteLine(e); sw.Close();
38、160; public static void TraceWrite(string message, string category)
39、 try if (category = "I") &
40、#160; TraceSwitch mySwitch = new TraceSwitch("BizImpTrace", &q
41、uot;Biztalk trace message"); if (mySwitch.TraceError)
42、 Write(message, "BizImpException");
43、; /Trace.Listeners1.WriteLine(message, "BizImpException");
44、 else if (category = "E")
45、 TraceSwitch mySwitch = new TraceSwitch("BizExTrace", "Biztalk trace message");
46、; if (mySwitch.TraceError)
47、 /System.Diagnostics.DefaultTraceListener = Trace.Listeners2; Write(message, "BizExExcepti
48、on"); /Trace.Listeners2.WriteLine(message, "BizImpException");
49、60; else if (category = "R")
50、60; TraceSwitch mySwitch = new TraceSwitch("BizRouterTrace", &
51、quot;Biztalk trace message"); if (mySwitch.TraceError)
52、; /System.Diagnostics.DefaultTraceListener = Trace.Listeners2; &
53、#160; Write(message, "BizRouterException"); /Trace.Listeners3.WriteLine(message, "BizRouterException");
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年山西太原市高职单招职业技能考试题库附完整答案详解(考点梳理)
- 2024年西安沣河职业学院高职单招职业适应性测试考试题库有完整答案详解
- 2027年六盘山职业学院高职单招职业适应性测试考试模拟试卷(考点提分)附答案详解
- 2026年漆水职业学院单招综合素质考试题库及答案详解(真题汇编)
- 2024年四川嘉陵江职业学院高职单招职业技能考试模拟试卷(精练)附答案详解
- 2025年贵州省遵义市单招综合素质考试模拟试卷及答案详解(名校卷)
- 2026年申江专修学院高职单招职业技能考试模拟试卷及参考答案详解(巩固)
- 2025年燕赵现代职业学院高职单招职业适应性测试考试模拟试卷完整版附答案详解
- 2027年山东外国语职大高职单招职业技能考试模拟试卷含完整答案详解【网校专用】
- 2024年青岛临港职业学院高职单招职业技能考试题库(易错题)附答案详解
- 神马股份帘子布发展公司招聘笔试题库2026
- 2026江苏南京江北新材料科技园管理办公室招聘5人笔试参考题库及答案详解
- 2026年医保政策培训试题(含答案)
- 01 必修上教材文言文逐篇过关挖空训练(解析版)2026版-高中语文文言文逐篇过关挖空训练
- 美容院激光脱毛技术标准化操作手册
- 医学26年:基层消化疾病防控要点 查房课件
- 初中八年级数学下册《直角三角形》单元学历案(基于北师大版)
- 评估业务报备管理制度
- 麻醉科双向转诊管理规范指南
- 室外消火栓施工组织设计方案
- 贝叶斯公式狼来了课件
评论
0/150
提交评论