How to extend the provided Trees in Kotlin?
mohit92 opened this issue · 1 comments
mohit92 commented
I want to extend the FileLoggingTree to add a default tag to all the logs but since the class is not open, I can not extend it.
MFlisar commented
Try v5.2.4
It allows you to provide a custom formatter like following:
L.formatter = DefaultFormatter()
You can extend the DefaultFormatter and add a prefix to any log line now.
Following would do what you want:
class MyFormatter: DefaultFormatter()
{
override fun formatLogPrefix(lumberjackTag: String?, stackData: StackData) : String {
return "MY-PREFIX-" + super.formatLogPrefix(lumberjackTag, stackData)
}
}