idictionary<string, object> dic = new dictionary<string, object>();
dic.add("属性:", category);
dic.add("内容:", message);
icollection<string> coll = new list<string>();
coll.add("general");
logentry log = new logentry();
log.priority = priority;
log.severity = severity;
log.message = category;//"日志测试";
log.timestamp = datetime.now;
log.extendedproperties = dic;//记录额外的信息
log.categories = coll;//设置记录的日志类型
logger.write(log);
}
public static void debug(string message)
{
info("debug", 1, traceeventtype.information, message);
}
public static void debugformat(string format, params object[] args)
{
info("debug", 1, traceeventtype.information, string.format(format, args));
}
public static void trace(string message)
{
info("trace", 1, traceeventtype.information, message);
}
public static void traceformat(string format, params object[] args)
{
info("trace", 1, traceeventtype.information, string.format(format, args));
}
public static void error(string message)
{
info("error", 1, traceeventtype.error, message);
}
public static void errorformat(string format, params object[] args)
{
info("error", 1, traceeventtype.error, string.format(format, args));
}
public static void error(object obj, exception ex)
{
info("error", 1, traceeventtype.error, string.format("error info:{0},{1}", obj, ex.message));
}
//日志记录
public static void writelog(string errortitle, string properties, string content)
{
idictionary<string, object> dic = new dictionary<string, object>();
dic.add("属性:", properties);
dic.add("内容:", content);
icollection<string> coll = new list<string>();
coll.add("general");
logentry log = new logentry();
log.message = errortitle;//"日志测试";
log.timestamp = datetime.now;
log.extendedproperties = dic;//记录额外的信息
log.categories = coll;//设置记录的日志类型
logger.write(log);
}
}
用法
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论