title: Class decorator to declare static member (e.g., for log4net)?
body: <p>I'm using log4net, and we have a lot of this in our code:</p>
  
  <pre><code>public class Foo {
      private static readonly ILog log = LogManager.GetLogger(typeof(Foo));
      ....
  }
  </code></pre>
  
  <p>One downside is that it means we're pasting this 10-word section all over, and every now and then somebody forgets to change the class name.  The <a href="http://log4net.sourceforge.net/release/1.2.0.30316/doc/manual/faq.html" rel="nofollow noreferrer">log4net FAQ</a> also mentions this alternative possibility, which is even more verbose:</p>
  
  <pre><code>public class Foo {
      private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
      ...
  }
  </code></pre>
  
  <p>Is it possible to write a decorator to define this?  I'd really like to say simply:</p>
  
  <pre><code>[LogMe]  // or perhaps: [LogMe("log")]
  public class Foo {
      ...
  }
  </code></pre>
  
  <p>I've done similar things in other languages, but never a statically-compiled language like C#.  Can I define class members from a decorator?</p>
  
  <p><strong>Edit</strong>: Heh.  I'm a Lisp programmer.  I appreciate the suggestions to switch languages, but really, if I was going to switch languages for better metaprogramming capabilities, I'd go all the way to Lisp instead of being half-assed about it.  Unfortunately using a different language isn't an option on this project.</p>