您的位置:首页 > 其它

微软企业库4.1学习笔记(三十七)日志模块 在应用中使用日志模块

2010-05-06 19:51 676 查看
  
代码

private void RecordSelectedCategories()
{

categories.Add("Trace");

}
protected void Button1_Click(object sender, EventArgs e)
{
RecordSelectedCategories();
LogEntry log = new LogEntry();
log.EventId = 100;
log.Priority = 3;
log.Message = "information message";
log.Categories = Categories;
Dic.Add("1", "<log><id>1</id><name>shiwenbin</name></log>");
Dic.Add("2", 2);
log.ExtendedProperties = Dic;

Logger.Write(log );

}
private IDictionary<string, object> Dic = new Dictionary<string, object>();

[NonSerialized]
private ICollection<string> categories = new List<string>(0);
[IgnoreMember]
public ICollection<string> Categories
{
get { return categories; }
set { this.categories = value; }
}

首先新建一个LogEntry,设置它的属性,设置日志记录使用的组Category为Trace,

log.Categories = Categories;

记录日志的时候,就会以Categories中设置的组包含日志类型进行记录。

未完待续。。。。。。。。。。。。。。。。。。。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐