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

Provide path of expected .config file in error message #227

Closed
FrankNuessle opened this issue Feb 6, 2025 · 2 comments · Fixed by #228
Closed

Provide path of expected .config file in error message #227

FrankNuessle opened this issue Feb 6, 2025 · 2 comments · Fixed by #228
Assignees
Milestone

Comments

@FrankNuessle
Copy link

FrankNuessle commented Feb 6, 2025

With log4net version 3.0.3:
I got the message:
"log4net:ERROR Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the and elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />"

It would be helpful to have the name + absolute path of "application's .config file" which is used by log4net, in the above error message of log4net.

Background:
When I'm running my unit tests with "dotnet test ..." I got the above error message and I analyzed and wonder, what's wrong with my AssemblyName.Test.dll.config.
I had to spend some effort and used then
log4net.Util.LogLog.InternalDebugging = true;
to find out, that when running
"dotnet test ..." for TFM = net8.0, the expected config file was "testhost.dll.config"!
If this information would be displayed in the above error message, I (and possibly other users) could save a lot of time.

@FreeAndNil
Copy link
Contributor

@FrankNuessle that's a good idea. I will adjust the error message.

You can set the assembly for which log4net searches a config file via

  log4net.Util.SystemInfo.EntryAssemblyLocation = typeof(MyTest).Assembly.Location;

That will probably fix your real problem.

@FreeAndNil FreeAndNil changed the title Provide path of application's .config file in error message Provide path of expected .config file in error message Feb 6, 2025
@FreeAndNil FreeAndNil self-assigned this Feb 6, 2025
@FreeAndNil FreeAndNil added this to the 3.0.4 milestone Feb 6, 2025
FreeAndNil added a commit that referenced this issue Feb 6, 2025
@FreeAndNil
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants