Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging multidimensional 2d array fails silently #2019

Open
emphasis87 opened this issue Mar 1, 2024 · 2 comments · May be fixed by #2035
Open

Logging multidimensional 2d array fails silently #2019

emphasis87 opened this issue Mar 1, 2024 · 2 comments · May be fixed by #2035
Labels

Comments

@emphasis87
Copy link

emphasis87 commented Mar 1, 2024

This fails silently:

var a = new object[1, 1]{ { "a" } };
Log.Error("{@Value}", a);

Is this expected behavior? I would expect this:
[["a"]]

@emphasis87 emphasis87 added the bug label Mar 1, 2024
@nblumhardt
Copy link
Member

Thanks for the report! The error behind the scenes is:

2024-03-01T21:21:16.5639620Z Exception caught while converting property value: System.ArgumentException: Array was not a one-dimensional array.
   at System.Array.GetValue(Int32 index)
   at Serilog.Capturing.PropertyValueConverter.TryConvertEnumerable(Object value, Type type, Destructuring destructuring, LogEventPropertyValue& result)
   at Serilog.Capturing.PropertyValueConverter.CreatePropertyValue(Object value, Destructuring destructuring, Int32 depth)
   at Serilog.Capturing.PropertyValueConverter.CreatePropertyValue(Object value, Destructuring destructuring)

In my test project I do see an event - it's:

[07:21:16 ERR] Capturing the property value threw an exception: ArgumentException

(The message there is what's substituted into the Value property.)

@chidamparam
Copy link

Can someone guide me to recreate and analyze the above issue so that I will go through the code and fix it

@sungam3r sungam3r linked a pull request Mar 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants