/// <summary> /// Clears the content of the GDC. /// </summary> public static void Clear() { GlobalDiagnosticsContext.Clear(); }
/// <summary> /// Gets the current thread MDC named item. /// </summary> /// <param name="item">Item name.</param> /// <param name="formatProvider">The <see cref="IFormatProvider"/> to use when converting a value to a string.</param> /// <returns>The value of <paramref name="item"/>, if defined; otherwise <see cref="String.Empty"/>.</returns> public static string Get(string item, IFormatProvider formatProvider) { return(GlobalDiagnosticsContext.ConvertToString(GetObject(item), formatProvider)); }
/// <summary> /// Checks whether the specified item exists in the Global Diagnostics Context. /// </summary> /// <param name="item">Item name.</param> /// <returns>A boolean indicating whether the specified item exists in current thread GDC.</returns> public static bool Contains(string item) { return(GlobalDiagnosticsContext.Contains(item)); }
/// <summary> /// Removes the specified item from the Global Diagnostics Context. /// </summary> /// <param name="item">Item name.</param> public static void Remove(string item) { GlobalDiagnosticsContext.Remove(item); }
/// <summary> /// Gets the Global Diagnostics Context named item. /// </summary> /// <param name="item">Item name.</param> /// <returns>The item value of string.Empty if the value is not present.</returns> public static string Get(string item) { return(GlobalDiagnosticsContext.Get(item)); }
/// <summary> /// Sets the Global Diagnostics Context item to the specified value. /// </summary> /// <param name="item">Item name.</param> /// <param name="value">Item value.</param> public static void Set(string item, string value) { GlobalDiagnosticsContext.Set(item, value); }
/// <summary> /// Gets the Global Diagnostics Context item. /// </summary> /// <param name="item">Item name.</param> /// <param name="formatProvider"><see cref="IFormatProvider"/> to use when converting the item's value to a string.</param> /// <returns>The value of <paramref name="item"/> as a string, if defined; otherwise <see cref="String.Empty"/>.</returns> /// <remarks>If <paramref name="formatProvider"/> is <c>null</c> and the value isn't a <see cref="string"/> already, this call locks the <see cref="LogFactory"/> for reading the <see cref="LoggingConfiguration.DefaultCultureInfo"/> needed for converting to <see cref="string"/>. </remarks> public static string Get(string item, IFormatProvider formatProvider) { return(GlobalDiagnosticsContext.Get(item, formatProvider)); }
/// <summary> /// Gets all messages from the stack, without removing them. /// </summary> /// <param name="formatProvider">The <see cref="IFormatProvider"/> to use when converting a value to a string.</param> /// <returns>Array of strings.</returns> public static string[] GetAllMessages(IFormatProvider formatProvider) { return(ThreadStack.Select((o) => GlobalDiagnosticsContext.ConvertToString(o, formatProvider)).ToArray()); }
/// <summary> /// Pops the top message from the NDC stack. /// </summary> /// <param name="formatProvider">The <see cref="IFormatProvider"/> to use when converting the value to a string.</param> /// <returns>The top message, which is removed from the stack, as a string value.</returns> public static string Pop(IFormatProvider formatProvider) { return(GlobalDiagnosticsContext.ConvertToString(PopObject(), formatProvider)); }