Reputation: 230058
In Play 2, I used this code to get a logger:
public class LoggerHelper {
public static Logger getLogger() {
final Throwable t = new Throwable();
t.fillInStackTrace();
final String fullClassName = t.getStackTrace()[1].getClassName();
return Logger.getLogger(fullClassName);
}
}
public class MyController {
private final static Logger logger = LoggerHelper.getLogger();
}
In Play 2, the code sample I found looked something for getting a logger looked something like this:
class MyController {
private val log = Logger(classOf[MyController])
...
}
How can I generify it not to include the class name?
Upvotes: 2
Views: 1662
Reputation: 771
Perhaps I'm misreading your question, but it looks like all you need is
class MyController {
private val log = Logger(this.getClass)
...
}
or have I misunderstood your needs?
Upvotes: 4