Reputation: 77
I implemented a simple
trait Logging {
...
object log {
def info(msg: String)
...
}
//saves stuff
def logOut(path) = {}
setting up a full log4j takes a ton of time with all the properties file required
Logging seems to be working fine except for the fact that I need to make a logOut at the end of my main() to print or save those logs somewhere, which is inconvenient and ugly
So the questions are :
Upvotes: 0
Views: 78
Reputation: 7926
You can add Shutdown hook at the end of your program. But keep in mind that it will only be executed in case of graceful shutdown. Killing the process will not invoke this hook.
sys.addShutdownHook { println("Bye-bye") }
Upvotes: 2