Hmm... I write this code in Scala.
class ThreadedFileAppender[E] extends FileAppender[E]{
private val appenders = Map[String,FileAppender[E]]()
override def start = {
started=true
}
override def subAppend(event:E) = {
val key = Thread.currentThread.getName
(if (appenders.isDefinedAt(key))
appenders(key)
else {
import java.text.SimpleDateFormat, java.util.Calendar
val appender = new FileAppender[E]
appender.setAppend(append)
appender.setContext(context)
appender.setEncoder(getEncoder)
appender.setFile(rawFileProperty
.replaceAll("%thread",Thread.currentThread.getName)
.replaceAll("%date",(new SimpleDateFormat("yyyy.MM.dd")).format(Calendar.getInstance.getTime)))
appender.setName(name)
appender.setPrudent(isPrudent)
appender.start
appenders(key) = appender
appender
}).doAppend(event)
}
}
But!... this don't work as expected :(
LogBack writes in separate files, but messages are "randomly" mixed :(
Where is my mistake?