Jaroslaw,
First of all, I just want to pat you on the back and say that you have created a pretty amazing logging system. I'm impressed with the flexibility, but I'm most impressed with the documentation--it makes it easy to implement and customize.
I noticed in a post that you said that reflection was used all over the place and that was going to cause a problem with modifying NLog to work in a medium trust environment. Reflection will work fine in a medium trust environment. What WON'T work are calls to unmanaged code which includes constructors for unmanaged objects. If you try to reflect into an unmanaged object in a Medium trust environment, your code will throw an exception.
I have an API that can be configured to use MSMQ (which will not work in a Medium trust environment). I have this code working in a medium trust environment by making sure none of the the methods that call MSMQ code (including constructors) are called when I'm in a medium trust environment. This way, I can use all of the other functionality of the API on those systems.
It's interesting to note that in your managed methods, it is not enough to wrap a call to unmanaged code in an if/then/else clause that doesn't get called if you are in a medium trust environment because the WHOLE method gets marked as requiring a higher trust level. What did was create wrappers for it like this:
ManagedMethod()
{
If IamTrusted then
{
UnmanagedWrapper()
}
}
UnmanagedWrapper()
{
CreateUnmanagedObjects
CallUnmanagedMethods()
}
If you instead do the following, it will blow up in a medium trust environment. It actually blows up when the ManagedMethod() is called:
ManagedMethod() <-- call to this in medium trust will "blow up"
{
If IamTrusted then
{
CreateUnmanagedObjects
CallUnmanagedMethods()
} else {
DoSomethingManaged()
}
}
I hope this helps clarify the issue a little. My real hope is that you support medium trust in 2.0 and release it SOON. I really want to use your API, but 95% of my need for it is in medium trust environments. I have only been working with your API for about 3 days, but it did appear that there was a lot of unmanaged code, so I know it's a steep hill to climb at this point. It would mean rewriting some of your unmanaged code into managed code and worse yet, you would then either have to maintain two sets of methods, or possibly no longer support logging from unmanaged code.