What is the best way to get the name of the caller class in an object? <p>I could get this working using this:</p> <pre><code>scala&gt; object LOGGER { | def warning(msg: String)(implicit className:String) = { | className | } | } defined object LOGGER scala&gt; class testing { | lazy implicit val className = this.getClass.getName | def test = LOGGER.warning("Testing") | } defined class testing scala&gt; val obj = new testing() obj: testing = testing@11fb4f69 scala&gt; obj.test res51: String = testing &lt;======= scala&gt; class testing2 { | lazy implicit val className = this.getClass.getName | def test = LOGGER.warning("Testing") | } defined class testing2 scala&gt; val obj2 = new testing2() obj2: testing2 = testing2@2ca3a203 scala&gt; obj2.test res53: String = testing2 &lt;===== </code></pre> <p>I also tried using Thread.currentThread.getStackTrace in the <code>object LOGGER</code> but couldn't get it to print the calling class <code>testing</code> in the <code>warning</code> function. Any other ways to do this?</p>