Ok based on your comments I think i understand now.
I think what you need to look into is Dependency injection. For example, Ninject library. There are others but i prefer ninject.
A beginner article:
An Absolute Beginner's Tutorial on Dependency Inversion Principle, Inversion of Control and Dependency Injection[
^]
The gist of it is what you are saying. Your class (MyWebServiceImpl) has to know that it is receiving the Log class. Instead what you would do is create an interface called ILog and have the class MyWebServiceImpl receive ILog as a param.
In doing that, your class can use any class that inherits from ILog for logging. You could have a DB Logger called DBLog, a File logger called Log, or a console output logger called ConsoleLog, but as long as the class inherits from ILog, your MyWebServiceImpl doesn't have to know the specific concrete class it is using.
You can use manual dependency injection in a way such as this
public interface ILog
{
void Log(string msg);
}
public class SqlLog : ILog
{
public void Log(string msg)
{
}
}
public class FileLog : ILog
{
public void Log(string msg)
{
}
}
Then in your class MyWebServiceImpl you would do something like
public class MyWebServiceImpl
{
private readonly ILog _log = null;
public MyWebServiceImpl(ILog logger)
{
this._log = logger;
}
}
This way, your class MyWebServiceImpl isn't dependent upon only using SqlLog or FileLog...it can use either. The usage would be something like
ILog logger = new SqlLog();
var srv = new MyWebServiceImpl(logger);
ILog filelogger = new FileLog();
var srv1 = new MyWebServiceImpl(filelogger);
And not your class isn't dependent upon any one logger type due to the manual dependency injection being done by using ILog.
I do encourage you to look into ninject though.