【问题标题】:Log4Net How to Log plain text without timeLog4Net 如何在没有时间的情况下记录纯文本
【发布时间】:2019-03-29 19:57:03
【问题描述】:

我正在使用 Log4Net.dll v1.2.10 将日志写入文本文件。 以下是我记录信息的方式:

Private loger As ILog = LogManager.GetLogger("MyAppName")

loger.Debug("some message")

这是我在日志文本文件中看到的内容:

2018-10-25 13:46:15,970 [6] DEBUG - [MyAppName] some message

我的问题:是否可以只在文件中记录“一些消息”文本而没有时间戳和其他额外信息?

任何类型的解决方案或解决方法都将受到高度赞赏。

【问题讨论】:

  • 在您的配置文件中查找appenderlayoutconversionPattern 并参考此链接获取documentation

标签: c# vb.net logging log4net


【解决方案1】:

这很容易。配置您的文件附加程序以使用此布局模式:

<layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%message%newline" />
</layout>

【讨论】:

    猜你喜欢
    • 2010-11-17
    • 1970-01-01
    • 2011-06-09
    • 1970-01-01
    • 2015-12-25
    • 1970-01-01
    • 2015-05-24
    • 1970-01-01
    相关资源
    最近更新 更多