Why doesn't \ n work in the Log.Info method?

\ n in the String.Format method below in Log.Info prints "\ n" as text instead of starting a new line; why doesn't it work? Any ideas? How can I make it work?

Log.Info(String.Format("Some arguments : \n Since : {0}\nBefore: {1}\nLog file name : {2}", since, before,logFileName)); 

Thanks!

+4
source share
1 answer

In windows, the string is actually \r\n . Try Environment.NewLine :

 Log.Info(String.Format("Some arguments : "+Environment.NewLine+" Since : {0}"+Environment.NewLine+"Before: {1}"+Environment.NewLine+"Log file name : {2}", since, before,logFileName)); 
+10
source

Source: https://habr.com/ru/post/1444049/


All Articles