Sample Code:

            try
{
string re = "1.1".Substring(1,4);
}
catch (Exception ex)
{ logger.ErrorFormat("Exception:\n{0}\n BaseException:\n{1} \n GetType:\n{2} \nMessage:\n{3}\n StackTrace:\n{4}", ex, ex.GetBaseException(), ex.GetType(), ex.Message, ex.StackTrace);
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }Output:

DayListExtractor.Form1 - Exception:
System.ArgumentOutOfRangeException: 索引和长度必须引用该字符串内的位置。
参数名: length
在 System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
在 System.String.Substring(Int32 startIndex, Int32 length)
在 DayListExtractor.Form1.Form1_Load(Object sender, EventArgs e) 位置 G:\test\DayListExtractor\Form1.cs:行号 63
BaseException:
System.ArgumentOutOfRangeException: 索引和长度必须引用该字符串内的位置。
参数名: length
在 System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
在 System.String.Substring(Int32 startIndex, Int32 length)
在 DayListExtractor.Form1.Form1_Load(Object sender, EventArgs e) 位置 G:\test\DayListExtractor\Form1.cs:行号 63
GetType:
System.ArgumentOutOfRangeException
Message:
索引和长度必须引用该字符串内的位置。
参数名: length
StackTrace:
在 System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
在 System.String.Substring(Int32 startIndex, Int32 length)
在 DayListExtractor.Form1.Form1_Load(Object sender, EventArgs e) 位置 G:\test\DayListExtractor\Form1.cs:行号 63

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

总结:

在需要看情况信息时,打印Exepection ex 实例即可

了解下C#异常时的输出的更多相关文章

  1. 编写高质量代码改善C#程序的157个建议[用抛异常替代返回错误、不要在不恰当的场合下引发异常、重新引发异常时使用inner Exception]

    前言 自从.NET出现后,关于CLR异常机制的讨论就几乎从未停止过.迄今为止,CLR异常机制让人关注最多的一点就是“效率”问题.其实,这里存在认识上的误区,因为正常控制流程下的代码运行并不会出现问题, ...

  2. tomcat不能多次startup.sh,异常时直接,分析logs目录下的日志。

    tomcat不能多次startup.sh,异常时直接干掉其进程. 分析logs目录下的日志.

  3. 出现异常时直接把e输出比输出e.getMessage()好得多

    之前研究态度不好,出异常时处理草草了事,今天出现问题才觉得该认真对待每个分支.

  4. ArrayList的ConcurrentModificationException异常和多线程下的异常

    一.ConcurrentModificationException ArrayList源码看为什么出现异常: public class ArrayList<e> extends Abstr ...

  5. 编写高质量代码改善C#程序的157个建议——建议59:不要在不恰当的场合下引发异常

    建议59:不要在不恰当的场合下引发异常 常见的不易于引发异常的情况是对在可控范围内的输入和输出引发异常. private void SaveUser3(User user) { ) { throw n ...

  6. Asp.net 4.0,首次请求目录下的文件时响应很慢

    原文:Asp.net 4.0,首次请求目录下的文件时响应很慢 1. 问题起因2. 尝试过的处理思路3. 解决方法 1. 问题起因 一个从VS2003(.Net Framework 1.1)升级到.ne ...

  7. Effective Java 第三版——69. 仅在发生异常的条件下使用异常

    Tips 书中的源代码地址:https://github.com/jbloch/effective-java-3e-source-code 注意,书中的有些代码里方法是基于Java 9 API中的,所 ...

  8. 微软BI 之SSIS 系列 - 在 SSIS 中将指定目录下的所有文件分类输出到不同文件夹

    开篇介绍 比如有这样的一个需求,旧的一个业务系统通常将产出的文件输出到同一个指定的目录下的不同子目录,输出的文件类型有 XML,EXCEL, TXT 这些不同后缀的文件.现在需要在 SSIS 中将它们 ...

  9. linux下安装Oracle时交换空间不足的解决方法

    摘:linux下安装Oracle时交换空间不足的解决方法 linux上安装Oracle时交换空间不足的解决办法 增加交换空间有两种方法: 严格的说,在系统安装完后只有一种方法可以增加swap,那就是本 ...

随机推荐

  1. RobotFramework与Jenkins集成发送邮件

    转: A.    目标:实现RobotFramework的脚本定时自动执行,执行完后自动将结果发送到指定邮箱 B.    前提1. 配置好Robot Framework的环境,脚本可以正常运行 2. ...

  2. solr的schema.xml配置属性解释

    schema.xml做什么? SOLR加载数据,创建索引和数据时,核心数据结构的配置文件是schema.xml,该配置文件主要用于配置数据源,字段类型定义,搜索类型定义等.schema.xml的配置直 ...

  3. 设置CameraRollBrowseOptions的宽高

    在利用air的CameraRoll调取ios设备的相册时需要定义位置.我们一般这么操作 var crOpts:CameraRollBrowseOptions = new CameraRollBrows ...

  4. 使用httpclient对zip格式的响应数据解压

    HttpResponse response = httpClient.execute(httpPost); //对zip进行解压 response.setEntity(new GzipDecompre ...

  5. python-json.loads()保持原json字符串的顺序

    import jsonfrom collections import OrderedDictmetadata = json.loads(text, object_pairs_hook=OrderedD ...

  6. 2016级算法第三次上机-E.ModricWang's Polygons

    930 ModricWang's Polygons 思路 首先要想明白,哪些多边形可能是格点正多边形? 分情况考虑: 三角形不可能,因为边长为有理数的正三角形的面积为无理数,而格点三角形的面积为有理数 ...

  7. AIMR 固定收益推荐读物

    目录 AIMR Suggested Fixed-Income Readings I. Perspectives on Interest Rates and Pricing of Traditional ...

  8. 常见浏览器hack汇总

    1.背景渐变bug: ①.ie8 ie9:用滤镜的方式解决: -ms-filter:"progid:DXImageTransform.Microsoft.gradient(GradientT ...

  9. ZOJ - 3946-Highway Project(最短路变形+优先队列优化)

    Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can ...

  10. Java返回泛型的方法-实例

    package com.frank.app; import java.io.UnsupportedEncodingException;import java.lang.reflect.Type;imp ...