System.FormatException in LoggingExtensions #129
Description
Title
When logging level is Debug, calling XmlKeyManager.ProcessKeyElement(XElement keyElement) will cause a System.FormatException: Input string was not in a correct format.
exception
Functional impact
Unable to use DataProtection API (and therefore any authentication)
Minimal repro steps
dnx451 with dnx 1.0.0-rc2-20213 clr x86 win
All AspNetCore assemblies are 1.0.0-rc2-20230 (from aspnetcidev)
Project is available : https://github.com/NatMarchand/FormatExceptionRepro
Using MVC + OpenIdConnect authentication
When navigating to a restricted uri (with [Authorize] on controller or method)
LogLevel = Debug (works correctly in LogLevel = Information)
Expected result
No exception (and logging "found key")
Actual result
Error 500 :
System.Format exception : Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Further technical details
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at System.Diagnostics.Debug.WriteLine(String format, Object[] args)
at Microsoft.Extensions.Logging.Debug.DebugLogger.DebugWriteLine(String message, String name)
at Microsoft.Extensions.Logging.Debug.DebugLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter)
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter)
--- End of inner exception stack trace ---
at Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func3 formatter)
at Microsoft.Extensions.Logging.LoggerMessage.<>c__DisplayClass5_01.<Define>b__0(ILogger logger, T1 arg1, Exception exception)
at Microsoft.Extensions.Logging.LoggingExtensions.FoundKey(ILogger logger, Guid keyId)
at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.ProcessKeyElement(XElement keyElement)