How can I output "console.write" -line output (without a new line) using NLog?

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

${message} new line added by default.

+4
source share
4 answers

I hope I understand your meaning, it seems that you have new string characters in the line you want to write, which forces it to go to a new line in the console if you replace the newline characters with an empty line, as shown below.

 string Message = "testMessage\r\n"; Console.Write(Message.Replace("\r\n","")); 
+1
source

To register items in the console, use console.log (item).

0
source

There seems to be a property called LineEndingMode / LineEnding that you can try changing.

0
source

The filetarget file has the LineEnding property, which can be set to the following values:

  • Default - Insert a platform-specific end line after each line.
  • CR - Insert a CR character (ASCII 13) after each line.
  • CRLF - Insert a CR LF sequence (ASCII 13, ASCII 10) after each row.
  • LF - Insert an LF character (ASCII 10) after each line.
  • None - Do not insert lines at the end.

In your case, you need None , therefore:

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

If you need it for another purpose, for example. ConsoleTarget, then this is not implemented. open the problem on github .

0
source

All Articles