feat: static loggers initialisation
```kotlin
private LOGGER = logger()
class X{
}
```
compiles to a real static java field
```java
private static final KotlinLogger LOG = logger((Function0)null.INSTANCE);
```
**where as**
```kotlin
class X {
companion object {
private LOGGER = logger()
}
}
```
compiles to something like this, which leads to multiple method invocations everytime the logger is used
```java
public static final class Companion implements Logging {
public KotlinLogger getLogger() {
return DefaultImpls.getLogger(this);
}
}
```
diff --git a/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/LoggingFactory.kt b/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/LoggingFactory.kt
index d4ee57c..87bc304 100644
--- a/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/LoggingFactory.kt
+++ b/log4j-api-kotlin/src/main/kotlin/org/apache/logging/log4j/kotlin/LoggingFactory.kt
@@ -36,6 +36,28 @@
fun logger(name: String): KotlinLogger = KotlinLogger(LogManager.getContext(false).getLogger(name))
/**
+ * Named logger instantiation. Useful outside of objects to create static loggers.
+ *
+ * **Usage**
+ * ```
+ * private val LOGGER = logger {}
+ * class X {
+ * // LOGGER.info("helo world")
+ * }
+ * ```
+ * ```
+ */
+fun logger(_context: () -> Unit) = logger(
+ with(_context::class.java.name) {
+ when {
+ contains("Kt$") -> substringBefore("Kt$")
+ contains("$") -> substringBefore("$")
+ else -> this
+ }
+ }
+)
+
+/**
* @see [logger]
*/
@Deprecated("Replaced with logger(name)", replaceWith = ReplaceWith("logger"), level = DeprecationLevel.WARNING)