private string GetStringValue(LogEventInfo logEvent) { DateTime timestamp = GetValue(logEvent); var cachedDateFormatted = _cachedDateFormatted; if (cachedDateFormatted.Date != timestamp.Date) { var formatTime = timestamp.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); _cachedDateFormatted = cachedDateFormatted = new CachedDateFormatted(timestamp.Date, formatTime); } return(cachedDateFormatted.FormattedDate); }
/// <summary> /// Renders the current short date string (yyyy-MM-dd) and appends it to the specified <see cref="StringBuilder" />. /// </summary> /// <param name="builder">The <see cref="StringBuilder"/> to append the rendered data to.</param> /// <param name="logEvent">Logging event.</param> protected override void Append(StringBuilder builder, LogEventInfo logEvent) { var timestamp = logEvent.TimeStamp; if (UniversalTime) { timestamp = timestamp.ToUniversalTime(); } var cachedDateFormatted = _cachedDateFormatted; if (cachedDateFormatted.Date != timestamp.Date) { var formatTime = timestamp.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); _cachedDateFormatted = cachedDateFormatted = new CachedDateFormatted(timestamp.Date, formatTime); } builder.Append(cachedDateFormatted.FormattedDate); }