NLog.IndentException 0.1.9

NLog logger indent exception layout renderer. Allows to indent exception stack in log file and to aviod exception stack surplus logging.
Can be parameterized not to log stack trace for console window.

Install-Package NLog.IndentException -Version 0.1.9
dotnet add package NLog.IndentException --version 0.1.9
<PackageReference Include="NLog.IndentException" Version="0.1.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NLog.IndentException --version 0.1.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
console log sample

Here is console output for layout like layout=&quot;${level} ${message}${onexception:${newline}${IndentException:LogStack=false:separator=&amp;#x9;:beforeType=:aftertype=}}&quot;
there is no stack trace shown (because of LogStack=false)

Error tryException failure
        ArgumentException       outer exception
        KeyNotFoundException    innerException
Error failed to start NLogTest
        ArgumentException       bad try
        ArgumentException       outer exception
        KeyNotFoundException    innerException
file log sample

Below you can find file logging sample using layout layout=&quot;[${threadid}] ${longdate} ${level} (${logger}) ${message}${onexception:${newline}${IndentException}}

outer exception and inner exception stack trace is logged only once. Error type and message are logged only if error processing code tries to log the same exception second time

[1] 2019-01-27 19:56:57.7258 Debug (YourNamespace.NLog.Extention.Test.Program) starting
[1] 2019-01-27 19:56:57.7769 Error (YourNamespace.NLog.Extention.Test.Classes.UnitOfWork) tryException failure
	[ArgumentException] outer exception
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.outerException()
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.tryException()
	[KeyNotFoundException] innerException
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.innerException()
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.outerException()
[1] 2019-01-27 19:56:57.7769 Error (YourNamespace.NLog.Extention.Test.Program) failed to start NLogTest
	[ArgumentException] bad try
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.tryException()
		at YourNamespace.NLog.Extention.Test.Program.Main(String[] args)
	[ArgumentException] outer exception
	[KeyNotFoundException] innerException
[1] 2019-01-27 19:56:57.8344 Debug (YourNamespace.NLog.Extention.Test.Program) the end
console log sample

Here is console output for layout like layout=&quot;${level} ${message}${onexception:${newline}${IndentException:LogStack=false:separator=&amp;#x9;:beforeType=:aftertype=}}&quot;
there is no stack trace shown (because of LogStack=false)

Error tryException failure
        ArgumentException       outer exception
        KeyNotFoundException    innerException
Error failed to start NLogTest
        ArgumentException       bad try
        ArgumentException       outer exception
        KeyNotFoundException    innerException
file log sample

Below you can find file logging sample using layout layout=&quot;[${threadid}] ${longdate} ${level} (${logger}) ${message}${onexception:${newline}${IndentException}}

outer exception and inner exception stack trace is logged only once. Error type and message are logged only if error processing code tries to log the same exception second time

[1] 2019-01-27 19:56:57.7258 Debug (YourNamespace.NLog.Extention.Test.Program) starting
[1] 2019-01-27 19:56:57.7769 Error (YourNamespace.NLog.Extention.Test.Classes.UnitOfWork) tryException failure
	[ArgumentException] outer exception
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.outerException()
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.tryException()
	[KeyNotFoundException] innerException
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.innerException()
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.outerException()
[1] 2019-01-27 19:56:57.7769 Error (YourNamespace.NLog.Extention.Test.Program) failed to start NLogTest
	[ArgumentException] bad try
		at YourNamespace.NLog.Extention.Test.Classes.UnitOfWork.tryException()
		at YourNamespace.NLog.Extention.Test.Program.Main(String[] args)
	[ArgumentException] outer exception
	[KeyNotFoundException] innerException
[1] 2019-01-27 19:56:57.8344 Debug (YourNamespace.NLog.Extention.Test.Program) the end

Release Notes

.Net standard project format is supported

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.1.9 126 3/7/2019
0.1.7 115 2/15/2019
0.1.6 174 1/15/2019
0.1.5 179 1/14/2019