Q:

How do I make log4net.dll optional? 

I use log4net to implement logging in my .NET app. 
However I do not want to distribute the 300kb log4net.dll for every user but instead send this dll to the user if he has problems and I want him to provide logs. 
So, is it possible to make my app run whether or not the dll is there?  
Of course for logging the dll would be needed, but if no logging is needed, the app should run without the dll. 

A:

Yes, it is possible. 
First create an interfase with all your log methods:
public interface ILogger
{
    void Write(string message);
    // And much more methods. 
}

Now create two instances, a dummy instance (lets call it DummyLogger), and a instance which will send its messages to Log4Net (Log4NetLogger). 
To finish, create a factory class:
static public class LogFactory
{
     static public ILogger CreateLogger()
     {
          if (/*Check if Log4Net is available*/)
               return new Log4NetLogger();
          else
               return new DummyLogger();
     }
}

You could check if Log4Net is available by simply checking if the file is in your bin-folder.  Something like:
File. Exists(AppDomain. CurrentDomain. BaseDirectory + "Log4Net.dll")

But I can imagine that you want to do other checks, like if it exists in the GAC or whatever. 
Now you can use your factory to create your logger and "write" messages to the log:
ILogger logger = LoggerFactory. CreateLogger();
logger. Write("I am logging something!");