title: this.getClass usage in Scala traits
body: <p>Can somebody explain why this code works in that way? I wanted to make my own proof of concept Loggable trait. The plan was to instantiate a logger instance in order that inherited classes do not have to do that work. But as I can see this is not what I wanted.</p>
  
  <p>Here is the code:</p>
  
  <pre class="lang-scala prettyprint-override"><code>package hu.jonas.simple
  
  trait Loggable {
    val logger = java.util.logging.Logger.getLogger(this.getClass.getName)
  
    def whoAmI = {
      logger.info(this.getClass.getName)
    }
  }
  
  class Service extends Loggable {
    def answer = {
      whoAmI
    }
  }
  
  object Main extends App {
    new Service().answer
  }
  </code></pre>
  
  <p>It produced the following log message:</p>
  
  <pre><code>Jan 25, 2013 2:02:07 PM hu.jonas.simple.Loggable$class whoAmI
  INFO: hu.jonas.simple.Service
  </code></pre>
  
  <p>Why do the two this.getClass.getName differ? And moreover what should I need to write when I instantiate the logger in order to get this:</p>
  
  <pre><code>Jan 25, 2013 2:02:07 PM hu.jonas.simple.Service whoAmI
  INFO: hu.jonas.simple.Service
  </code></pre>