I just went through all that βgot punished from IDEAβ and I have this solution for you ...
Add Logback and slf4s to your POM:
<dependency> <groupId>com.weiglewilczek.slf4s</groupId> <artifactId>slf4s_${scala.version}</artifactId> <version>1.0.7</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>0.9.30</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.30</version> </dependency>
NOTES:
I used $ {scala.version} in artfactId slf4s - make sure you have it defined or replace it with 2.9.1 or something like that.
In addition, you will need a scala -tools repository available for dependencies too, which I assume you will have, as I think, you need to compile it.
Then add a file called logback.xml to the resource folder containing this:
<configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%date,%d{HH:mm:ss.SSS},%thread,%-5level,%logger{36},%line,%msg%n</pattern> </encoder> </appender> <root level="TRACE"> <appender-ref ref="STDOUT"/> </root> </configuration>
My template is potentially a bit weird - it's actually from an appender file that spits it out as a CSV, which I can open graphically in Excel easily.
Then expand the Logging trait in your application like this:
import swing._ import com.weiglewilczek.slf4s.Logging object App extends SwingApplication with Logging { override def startup(args: Array[String]) { logger.info("Starting init...") } }
And in the console window there will be an informational message "Starting init ..." with a bunch of other things.
Logback and slf4s are the topics I'm connected to.
IMPORTANT AND AMAZING:
I cannot remember what he called, but the logging methods that you use to post messages have signatures such as information (message: => String) - as you can see in logger.scala .
This means that the expression or block that you pass to them will not be executed at all if the appropriate logging level is not included in the configuration file.
Thus, it only adds a method call and a flag check to the code when it is turned off - which is pretty sweet imho :)
Hope this helps, Seth.