为什么\ n在Log.Info方法中不起作用?

时间:2012-11-05 06:49:18

标签: c# .net log4net string-formatting

Log.Info中下面的String.Format方法中的\ n打印" \ n"作为文本而不是开始新的行;为什么它不起作用?任何的想法?我怎样才能使它发挥作用?

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

谢谢!

1 个答案:

答案 0 :(得分:10)

在Windows上,换行实际上是\r\n。试试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));