Skip to content

Commit eae1ded

Browse files
authored
Merge pull request #368 from 0xced/Better-SelfLogs
Improve SelfLog when a configuration method is not found
2 parents ae0e57e + 4ab71a9 commit eae1ded

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Serilog.Settings.Configuration/Settings/Configuration/ConfigurationReader.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,17 +470,27 @@ static bool HasImplicitValueWhenNotSpecified(ParameterInfo paramInfo)
470470
.ToList();
471471

472472
if (!methodsByName.Any())
473-
SelfLog.WriteLine($"Unable to find a method called {name}. Candidate methods are:{Environment.NewLine}{string.Join(Environment.NewLine, candidateMethods)}");
473+
{
474+
if (candidateMethods.Any())
475+
{
476+
SelfLog.WriteLine($"Unable to find a method called {name}. Candidate methods are:{Environment.NewLine}{string.Join(Environment.NewLine, candidateMethods)}");
477+
}
478+
else
479+
{
480+
SelfLog.WriteLine($"Unable to find a method called {name}. No candidates found.");
481+
}
482+
}
474483
else
484+
{
475485
SelfLog.WriteLine($"Unable to find a method called {name} "
476486
+ (suppliedArgumentNames.Any()
477487
? "for supplied arguments: " + string.Join(", ", suppliedArgumentNames)
478488
: "with no supplied arguments")
479489
+ ". Candidate methods are:"
480490
+ Environment.NewLine
481491
+ string.Join(Environment.NewLine, methodsByName));
492+
}
482493
}
483-
484494
return selectedMethod;
485495
}
486496

0 commit comments

Comments
 (0)