Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.LogFormatter中存在的JsonLogFormatter的Template部分的语法是什么

问题描述

我需要以JSON格式将应用程序日志写入平面文件中。我的应用程序使用 用于编写日志的Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.LogFormatter。我无法编写“ Json类型”的模板部分。 我正在使用textformatter类型并添加引号和逗号来获取日志输出为JSON。

任何人都可以共享JsonLogFormatter的模板值。以下是我当前正在使用的配置文件

<formatters>
   <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.textformatter,Microsoft.Practices.EnterpriseLibrary.Logging"
        template=" { &#34;Timestamp&#34;:&#34;{timestamp(local)}&#34;,&#34;Message&#34;:&#34;{message}&#34;,&#34;Category&#34;:&#34;{category}&#34;,&#34;Priority&#34;:&#34;{priority}&#34;,&#34;Severity&#34;:&#34;{severity}&#34; }"
        name="Text Formatter"/>
</formatters>

输出

{ 
   "Timestamp":"17/08/2020 00:00:29","Message":"Application Stopped!!!","Category":"General","Priority":"5","Severity":"@R_619_4045@ion" 
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)