Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
2.7
-
None
Description
Recently I was trying to extend log4j2 library in my Kotlin project with @Plugin class. It is just simple converter, nothing special.
The problem was that log4j2 didn't load @Plugin annotated Kotlin class at all.
Made a small investigation and found out that Plugins are loaded by PluginProcessor during the compilation time(which is in my case was run by maven plugin). At that time Kotlin classes are not compiled yet, so PluginProcessor does not load Plugin class.
It is quite known problem with annotation processing for Kotlin.
Attaching some of Kotlin code if anybody wants to try it:
// code placeholder @Plugin(name = "TestConverter", category = "Converter") @ConverterKeys("m") class TestConverter(name: String, style: String) : LogEventPatternConverter(name, style) { companion object { @JvmStatic fun newInstance(options: Array<String>): TestConverter { return TestConverter("testConverter", Thread.currentThread().name) } } override fun format(logEvent: LogEvent, stringBuilder: StringBuilder) { //some stuff here } }