Highlight .NET Stack Trace In Exception - netStack.js
| File Size: | 11.2 KB |
|---|---|
| Views Total: | 2036 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
netStack.js is a minimal jQuery Vanilla JavaScript syntax highlighting plugin for .NET that enables you to highlight the exception information (stack traces) using your own CSS styles.
How to use it:
1. Insert your stack trace into a <pre> or <code> tag.
<pre class="stacktrace"> ConsoleApplication1.MyCustomException: some message .... ---> System.Exception: Oh noes! at ConsoleApplication1.SomeObject.OtherMethod() in C:\ConsoleApplication1\SomeObject.cs:line 24 at ConsoleApplication1.SomeObject..ctor() in C:\ConsoleApplication1\SomeObject.cs:line 14 --- End of inner exception stack trace --- at ConsoleApplication1.SomeObject..ctor() in C:\ConsoleApplication1\SomeObject.cs:line 18 at ConsoleApplication1.Program.DoSomething() in C:\ConsoleApplication1\Program.cs:line 23 at ConsoleApplication1.Program.Main(String[] args) in C:\ConsoleApplication1\Program.cs:line 13 </pre>
2. Download and insert the main script 'netstack.js' into the document.
<script src="/path/to/netStack.js"></script>
3. Initialize the plugin on the <pre> element.
const stack = new netStack('.stacktrace');
4. Apply your own styles to the highlighted strings.
pre, code {
background-color: #222;
color: #ffffff;
font-family:'Roboto Mono'
}
.st-type {
color: #0a8472;
font-weight: bolder;
}
.st-method {
color: #70c9ba;
font-weight: bolder;
}
.st-frame-params {
color: #ffffff;
font-weight: normal;
}
.st-param-type { color: #0a8472; }
.st-param-name { color: #ffffff; }
.st-file { color: #f8b068; }
.st-line { color: #ff4f68; }
5. Default values for classes.
const stack = new netStack('.stacktrace', {
frame: 'st-frame',
type: 'st-type',
method: 'st-method',
paramsList: 'st-frame-params',
paramType: 'st-param-type',
paramName: 'st-param-name',
file: 'st-file',
line: 'st-line'
});
Changelog:
v2.1.2 (2025-04-12)
- update
v2.1.1 (2025-01-23)
- removed multilanguage option
v2.0.0 (2024-08-29)
- Converted library to vanilla javascript.
- Added support for output from AggregateException.
- Fixed a bug where an inner exception was not correctly formatted.
- UMD compatibility added.
v1.2.0 (2023-11-23)
- Support for Chinese
v1.1.2 (2023-02-07)
- Language regex fix
2021-11-17
- Fix bug with "at" in error message
v1.1.0 (2021-10-02)
- Support for Russian stack traces.
- Fixed a bug where multiple instances of --- were not correctly indented.
2021-02-16
- Updated to version 1.0.14
2020-02-28
- Updated to version 1.0.13: Fixed Stacktrace not correctly formatted
2020-02-22
- Updated to version 1.0.12
2019-08-15
- Updated to version 1.0.11
2019-06-11
- Updated to version 1.0.10
2019-02-11
- Updated to version 1.0.9
2019-01-07
- Rename stacktrace.js
- JS update
2018/08/18
- Update stacktrace.js
This awesome jQuery plugin is developed by elmahio. For more Advanced Usages, please check the demo page or visit the official website.











