如何使用NLog输出"console.write"样式的输出(无换行符)? [英] How can I output "console.write"-style output (no newline) with NLog?

查看:528
本文介绍了如何使用NLog输出"console.write"样式的输出(无换行符)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将日志输出为console.write(),即没有换行符 NLog ?

How can I output log as console.write() i.e. no newline with NLog?

${message}默认为插入换行符.

推荐答案

filetarget具有属性LineEnding,可以将其设置为以下值:

The filetarget has the property LineEnding which could be set to the following values:

  • Default-在每行之后插入与平台相关的行尾序列.
  • CR-在每行之后插入CR字符(ASCII 13).
  • CRLF-在每行之后插入CR LF序列(ASCII 13,ASCII 10).
  • LF-在每行之后插入LF字符(ASCII 10).
  • None-不要插入任何结尾的行.
  • Default - Insert platform-dependent end-of-line sequence after each line.
  • CR - Insert CR character (ASCII 13) after each line.
  • CRLF - Insert CR LF sequence (ASCII 13, ASCII 10) after each line.
  • LF - Insert LF character (ASCII 10) after each line.
  • None - Don't insert any line ending.

在您的情况下,您需要None,所以:

In your case you need None, so:

 <target xsi:type="File"
          name="file1"
          lineEnding="None"

如果您在另一个目标中需要此功能,例如ConsoleTarget,然后未实现.请在GitHub上打开一个问题.

If you need this in another target, e.g. ConsoleTarget, then that isn't implemented. Please open an issue on GitHub.

这篇关于如何使用NLog输出"console.write"样式的输出(无换行符)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆