for configuring my logger in classes i use `MyClas...
# announcements
f
for configuring my logger in classes i use
MyClass::class.java.simpleName
. I want to setup a logger for my kotlin file (no classes inside), can I get the FQN of the kotlin file somehow? e.g.
com.example.stuff.UtilitiesKt
?
e
Try
MyClass::class.java.getCanonicalName()
Remember, by calling
::class.java
you get access to all the methods defined in
Class
from Java library
f
Thanks for the hint. Any idea about getting the FQN of the kotlin file?
s
Define a toplevel method and use:
tlm.javaMethod!!.declaringClass.name
f
perfect thanks. From you answer I assume there is no "kotlin native" i.e. JVM independent way to access it, right?
s
Not that I know of. I think at one point they wanted to introduce File and Package concepts in reflection but havent seen any of that yet.
f
👍