Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Microsoft企业日志中的扩展属性_C#_Logging_Enterprise Library - Fatal编程技术网

C# Microsoft企业日志中的扩展属性

C# Microsoft企业日志中的扩展属性,c#,logging,enterprise-library,C#,Logging,Enterprise Library,如果值为列表或数组,则会显示计数,是否有方法更改Microsoft Enterprise Logging中扩展属性的格式 目前,我正在使用它并手动传递计数 dictionary.Add(" Employee(Count)", EmpList.Count()); 在我使用的web配置中 Extended Properties : {dictionary({key} - {value}{newline})} 那么,有没有什么方法可以使格式通用化,这样,如果是普通字符串或int,它将显示实际内容,

如果值为列表或数组,则会显示计数,是否有方法更改Microsoft Enterprise Logging中扩展属性的格式

目前,我正在使用它并手动传递计数

dictionary.Add(" Employee(Count)", EmpList.Count());
在我使用的web配置中

Extended Properties : {dictionary({key} - {value}{newline})}

那么,有没有什么方法可以使格式通用化,这样,如果是普通字符串或int,它将显示实际内容,如果是数组或列表类型的输入,它将显示计数?我相信实现您想要的唯一方法是创建自定义格式化程序。您可以重用几乎所有现有的实现,但将实现从调用
GenericTextFormatter
更改为:

GenericTextFormatter入口格式化程序
=新的GenericTextFormatter(参数、处理程序);
调用您自己的自定义实现,根据对象类型执行
ToString()
Count()

GenericTextFormatter<KeyValuePair<string, object>> entryFormatter
            = new GenericTextFormatter<KeyValuePair<string, object>>(parameter, handlers);