-
Notifications
You must be signed in to change notification settings - Fork 934
Have more robust log4net loading #1837
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
Have more robust log4net loading #1837
Conversation
private static readonly Func<Assembly, string, object> GetLoggerByNameDelegate; | ||
private static readonly Func<System.Type, object> GetLoggerByTypeDelegate; | ||
|
||
static Log4NetLoggerFactory() | ||
{ | ||
LogManagerType = System.Type.GetType("log4net.LogManager, log4net", true); | ||
GetLoggerByNameDelegate = GetGetLoggerByNameMethodCall(); | ||
GetLoggerByTypeDelegate = GetGetLoggerMethodCall<System.Type>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method calls following the get type are using the type without checking if it was found, so better not allow GetType
to yield null
.
Reuse the logic from ReflectHelper, and mutualise it for all log4net type loadings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid mobile version makes all comments pending requiring a "submit"
Wouldn't it be enough to just |
The method is not even documented for usage with short names. With the GAC tendency to reject short names unless they are already loaded in the application domain, I would not rely on this. Since the code from |
But this is anyway what happens here. Isn't it? |
It happens with the |
The "logic fallback on searching among already loaded assemblies any loosely matching one for loading the type from it" has been added a few month back in 5.2 |
By yourself, granted, but the |
@fredericDelaporte could you send a fixed release version, i failed to build the dll. |
Expands the checks of this PR, find the "NHibernate (Release Package)" one and click on "Details". Teamcity may ask you for a login but an anonymous option is normally available. Then browse to the artifacts tab of the build and take what you need. But the current release build was not having artifacts, I do not know why. I have relaunched it, wait for it to complete if it is not finished yet. |
There was some discussion in this PR about whether the loading code could be simplified or not. I was, and still am, for keeping this code as near as possible to the loading logic of So, As proposed on the development group, and since no continued grounded disagreement has been expressed there since one week after raised concerns being addressed, I intend to merge this PR next week (likely on Wednesday). (I am issuing this notice on PR issued before starting to apply this handling of merges. I will not do it for new PR.) |
As I still disagree with this change - does it count as "continuous disagreement"? |
Of course, but I would like to better understand what cause you to still disagree. I believe to have explained why this change was the way it was, where you have expressed concerns. May you tell what is wrong with those explanations? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by now just to unblock 5.2. However, I still think that the code needs to be simplified and not related on the code borrowed from ReflectHelper
. Also, exception flow logic has to be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact changes are to be done.
Remove non-sense
Co-Authored-By: fredericDelaporte <12201973+fredericDelaporte@users.noreply.github.com>
In some circumstances, it appears the log4net loading mechanism may fail with null reference exceptions, which does not help understanding what is the trouble. (See #1836.)
Moreover, log4net loading is triggered after some probing logic which is in no way involved in how it is actually loaded, creating a possibility the probing considers it loadable while it is not.
Fixes #1836