title: better way to write wrapper class to get loose coupling
body: <pre><code>class LogUtil&lt;T&gt; : ILogUtility
  {
      log4net.ILog log;
  
      public LogUtil()
      {
          log = log4net.LogManager.GetLogger(typeof(T).FullName);
      }
  
      public void Log(LogType logtype, string message)
      {
          Console.WriteLine("logging coming from class {0} - message {1} " , typeof(T).FullName, message);
      }
  }
  
  public class Logger
  {
      ILogUtility _logutility;
  
      public Logger(ILogUtility logutility)
      {
          _logutility = logutility;
      }
  
  
      public void Log(LogType logtype, string message)
      {
          _logutility.Log(logtype, message);
      }
  
  
  }
  </code></pre>
  
  <p>I need to have the functionality to be flexible and have the ability to remove the LogUtil class in the future and use some thing else.</p>
  
  <p>So I write LoggerUtility wrapper class as follows:</p>
  
  <pre><code>class LoggerUtility&lt;T&gt;
  {
      public Logger logger
      {
          get
          {
  
              LogUtil&lt;T&gt; logutil = new LogUtil&lt;T&gt;();
  
              Logger log = new Logger(logutil);
  
              return log;
          }
      }
  }
  </code></pre>
  
  <p>My client code as follows:</p>
  
  <pre><code>public class TestCode
  {
      public void test()
      {
  
          new LoggerUtility&lt;TestCode&gt;().logger.Log(LogType.Info, "hello world");
  
      }
  
  }
  </code></pre>
  
  <p>I am coding Logger property which may not be clean.</p>
  
  <p>as you can see that following line does not look clean. </p>
  
  <pre><code>new LoggerUtility&lt;TestCode&gt;().logger.Log(LogType.Info, "hello world");
  </code></pre>
  
  <p>Is there a better way to write the client code? I want to have loose coupling with LogUtil and not use it directly in my client code. </p>
  
  <p>Please let me know.</p>
  
  <p>Thanks</p>