CallSite outputs the source-file-name and source-line-number where a LogEvent occurred. NLog scans the callstack and output the method-stackframe just before the NLog Logger takes over.
Platforms Supported: All
${callsite:className=Boolean:fileName=Boolean:includeSourcePath=Boolean:methodName=Boolean}
True
True
Introduced with NLog v4.4
False
True
True
True
Introduced with NLog v4.3.9. Before NLog 5.0 the default value was
False
.
True
Introduced with NLog v4.5. Before NLog 5.0 the default value was
False
.
0
Introduced with NLog 4.7.1
The Callsite-LayoutRenderer infers a heavy performance hit when doing lots of logging, as it has to capture full StackTrace for every log message. NLog 5.0 makes it possible to skip the StackTrace-capture, when using LogEventInfo.SetCallerInfo(...)
with input from Caller Information-attributes.
NLog 5.0 provides Fluent-Logger-API for easy capture of caller-information, and provides fast logging when using ${callsite:captureStackTrace=false}
:
_logger.ForInfoEvent() .Message("This is a fluent message {0}", "test") .Property("PropertyName", "PropertyValue") .Log();
If using Custom wrapper for NLog Logger, then make sure to provide the typeof(OwnWrapper)
as input, when calling NLog Logger:
Logger.Log(Type wrapperType, LogEventInfo logEvent)
Alternative if the custom Logger-wrapper comes from its own dedicated Assembly, then one can exclude the entire Assembly:
NLog.LogManager.AddHiddenAssembly(typeof(OwnWrapper).Assembly);
If symbol information is not available, then it will not be able to output source-code filename or line-number. Symbol information from PDB files must be deployed with the application to retrieve and output source-code line-number. For applications compiled in release mode, then inlining can occur and cause "unexpected" line-numbers.
If using Deterministic
builds then it will generate symbol information with relative paths:
<PropertyGroup> <Deterministic>true</Deterministic> <PathMap>$(SolutionDir)=./</PathMap> <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> </PropertyGroup>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4