title: Should I use log4net directly in my domain model objects?
body: <p>I'm wondering if it's bad practice to use log4net directly on my domain object... I'll be using ELMAH for my exceptions on the ASP.NET MVC application side, but for some informational purposes I'd like to log some data about the domain model itself.</p>
  
  <p>Given the following domain object:</p>
  
  <pre><code>   public class Buyer
  {
      private int _ID;
      public int ID
      {
          get { return _ID; }
          set
          {
              _ID = value;
          }
      }
  
      private IList&lt;SupportTicket&gt; _SupportTickets=new List&lt;SupportTicket&gt;();
      public IList&lt;SupportTicket&gt; SupportTickets
      {
          get
          {
              return _SupportTickets.ToList&lt;SupportTicket&gt;().AsReadOnly();
          }
      }
  
      public void AddSupportTicket(SupportTicket ticket)
      {
          if (!SupportTickets.Contains(ticket))
          {
              _SupportTickets.Add(ticket);
          }
      }
  }
  </code></pre>
  
  <p>Is adding logging behavior in the AddSupportTicketMethod a bad idea...so essentialy it'd look like this:</p>
  
  <pre><code>       public class Buyer
  {
      protected static readonly ILog log = LogManager.GetLogger(typeof(SupportTicket));
  
      public Buyer()
      {
         log4net.Config.XmlConfigurator.Configure();
      }
  
  
      private int _ID;
      public int ID
      {
          get { return _ID; }
          set
          {
              _ID = value;
          }
      }
  
      private IList&lt;SupportTicket&gt; _SupportTickets=new List&lt;SupportTicket&gt;();
      public IList&lt;SupportTicket&gt; SupportTickets
      {
          get
          {
              return _SupportTickets.ToList&lt;SupportTicket&gt;().AsReadOnly();
          }
      }
  
      public void AddSupportTicket(SupportTicket ticket)
      {
          if (!SupportTickets.Contains(ticket))
          {
              _SupportTickets.Add(ticket);
          } else {
             log.Warn("Duplicate Ticket Not Added.");
          }
      }
  }
  </code></pre>