1

我不得不从 log4net 转移到 entlib 记录器。我知道你在想什么?:)

无论如何,我正在尝试更改记录器的默认模板以摆脱无用的信息 - 例如优先级等。但我的日志仍然有它 - 所有这些值在日志中都是 null 或默认(值类型)创建的条目。这是模板:


<add template="Timestamp: {timestamp}{tab}Category: {category}{tab}Severity: {severity}{newline}
Process Id: {processId}{tab}Thread Id: {win32ThreadId}{newline}
Message: {message}"
      type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      name="Text Formatter" />

我仍然收到事件 ID、标题、机器、优先级和进程名称。任何帮助,将不胜感激。


有没有办法使用数字而不是时间戳来命名旧的翻转日志文件并指定最大翻转计数 - 就像在 log4net 中一样?

4

1 回答 1

1

在配置文件 (app.config) 中有一个元素格式化程序。您可以更改它(最好使用配置工具)。我的一个看起来像这样:

<add 
 template="{timestamp}  {machine}:{processId}:{threadName}({win32ThreadId}) {message}"
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    name="LogFileFormatter" />
于 2009-03-26T11:02:17.650 回答