src/NLog/Layouts/Layout.cs
/// <summary>
/// Optimized version of <see cref="Render(LogEventInfo)"/> for internal Layouts. Works best
/// when override of <see cref="RenderFormattedMessage(LogEventInfo, StringBuilder)"/> is available.
/// </summary>
/// <param name="logEvent">The event info.</param>
/// <param name="target">Appends the string representing log event to target</param>
/// <param name="cacheLayoutResult">Should rendering result be cached on LogEventInfo</param>
Optimized version of  for internal Layouts. Works best
when override of  is available.
Optimized version of for internal Layouts . Works best when override of is available .
internal void RenderAppendBuilder(LogEventInfo logEvent, StringBuilder target, bool cacheLayoutResult = false)
        {
            if (!IsInitialized)
            {
                Initialize(LoggingConfiguration);
            }
            if (!ThreadAgnostic || MutableUnsafe)
            {
                object cachedValue;
                if (logEvent.TryGetCachedLayoutValue(this, out cachedValue))
                {
                    target.Append(cachedValue?.ToString() ?? string.Empty);
                    return;
                }
            }
            cacheLayoutResult = cacheLayoutResult && !ThreadAgnostic;
            using (var localTarget = new AppendBuilderCreator(target, cacheLayoutResult))
            {
                RenderFormattedMessage(logEvent, localTarget.Builder);
                if (cacheLayoutResult)
                {
                    logEvent.AddCachedLayoutValue(this, localTarget.Builder.ToString());
                }
            }
        }
internal void RenderAppendBuilder ( LogEventInfo logEvent , StringBuilder target , bool cacheLayoutResult = false ) { if ( ! IsInitialized ) { Initialize ( LoggingConfiguration ) ; } if ( ! ThreadAgnostic || MutableUnsafe ) { object cachedValue ; if ( logEvent . TryGetCachedLayoutValue ( this , out cachedValue ) ) { target . Append ( cachedValue ? . ToString ( ) ?? string . Empty ) ; return ; } } cacheLayoutResult = cacheLayoutResult && ! ThreadAgnostic ; using ( var localTarget = new AppendBuilderCreator ( target , cacheLayoutResult ) ) { RenderFormattedMessage ( logEvent , localTarget . Builder ) ; if ( cacheLayoutResult ) { logEvent . AddCachedLayoutValue ( this , localTarget . Builder . ToString ( ) ) ; } } }
Optimized version of  for internal Layouts.
Optimized version of for internal Layouts .
// when needed as it generates garbage
logEvent
LogEventInfo
The event info.
The event info .
target
StringBuilder
Appends the string representing log event to target
Appends the string representing log event to target
cacheLayoutResult
bool
Should rendering result be cached on LogEventInfo
Should rendering result be cached on LogEventInfo