Scala slf4j dynamic file name

541 views Asked by At

I just successfully added Grizzled-SLF4J logger to my project using this link http://alvinalexander.com/scala/how-to-log-output-file-grizzled-slf4j-scala-simplelogger.properties

But using this properties, there is no option to create dynamic file name:

org.slf4j.simpleLogger.logFile         = /tmp/myapp.log
org.slf4j.simpleLogger.defaultLogLevel = info
org.slf4j.simpleLogger.showDateTime    = true
org.slf4j.simpleLogger.dateTimeFormat  = yyyy'/'MM'/'dd' 'HH':'mm':'ss'-'S
org.slf4j.simpleLogger.showThreadName  = true
org.slf4j.simpleLogger.showLogName     = true
org.slf4j.simpleLogger.showShortLogName= false
org.slf4j.simpleLogger.levelInBrackets = true

Is there any other logger for scala projects that allow me add dynamic file name, or how to do this using this library (I see it is just a wrapper for slf4j)

1

There are 1 answers

0
Bob Dalgleish On BEST ANSWER

The slf4j library is really an interface to some underlying logging implementation. You would have log4j, logback or some other logging implementation do the heavy lifting, with an adapter jar, as explained in the slf4j documentation.

You would then provide the details in the properties file for log4j for instance, where you can bind in dynamically constructed file names.