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
Logging 使用p&;p EntLib记录块_Logging_Enterprise Library - Fatal编程技术网

Logging 使用p&;p EntLib记录块

Logging 使用p&;p EntLib记录块,logging,enterprise-library,Logging,Enterprise Library,我正在使用模式与实践企业库(p&p EntLib)日志块写入文本文件 一些日志消息包含多行,我想强制这些行成为一行-换句话说,在将日志消息写入文件之前,将日志消息中的\r&\n替换为一个空格 如果可能的话,我该如何为此配置日志记录块?您需要从内存中创建一个自定义格式化程序,类似于 对消息执行字符串替换以用空格替换换行符怎么样 i、 e 配置格式化程序模板,如下所示: <formatters> <add template="{timestamp}: {category}: {

我正在使用模式与实践企业库(p&p EntLib)日志块写入文本文件

一些日志消息包含多行,我想强制这些行成为一行-换句话说,在将日志消息写入文件之前,将日志消息中的
\r
&
\n
替换为一个空格


如果可能的话,我该如何为此配置日志记录块?

您需要从内存中创建一个自定义格式化程序,类似于

对消息执行字符串替换以用空格替换换行符怎么样

i、 e

配置格式化程序模板,如下所示:

<formatters>
  <add template="{timestamp}: {category}: {severity}: {message}"
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null"
    name="My Text Formatter" />
</formatters>

这将生成一个日志文件,该文件如下所示:

11/11/2009 2:52:01 PM: My Category Event: Information: This is  the message to log.
11/11/2009 2:53:47 PM: My Category Event: Information: More test to log to the  file.
11/11/2009 2:52:01 PM: My Category Event: Information: This is  the message to log.
11/11/2009 2:53:47 PM: My Category Event: Information: More test to log to the  file.