提交当前本机整理版本
This commit is contained in:
@@ -37,4 +37,35 @@ namespace Lskj.Util
|
||||
{
|
||||
// 写入所有关键值对
|
||||
|
||||
WriteDictionary(writer, loggingEvent.
|
||||
WriteDictionary(writer, loggingEvent.Repository, loggingEvent.GetProperties());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过反射获取传入的日志对象的某个属性的值
|
||||
/// </summary>
|
||||
/// <param name="property"></param>
|
||||
/// <param name="loggingEvent"></param>
|
||||
/// <returns></returns>
|
||||
private object LookupProperty(string property, log4net.Core.LoggingEvent loggingEvent)
|
||||
{
|
||||
object propertyValue = default(object);
|
||||
PropertyInfo propertyInfo = null;
|
||||
Type objtype = loggingEvent.MessageObject.GetType();
|
||||
propertyInfo = objtype.GetProperty(property);
|
||||
|
||||
propertyValue = propertyInfo != null ? propertyInfo.GetValue(loggingEvent.MessageObject, null) : loggingEvent.LookupProperty(property);
|
||||
if (property == "msg" && objtype == typeof(String))
|
||||
{
|
||||
return loggingEvent.MessageObject;
|
||||
}
|
||||
|
||||
return propertyValue ?? "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user