I am developing a project in Kotlin and Spring and a question has arisen with a log and the time zone used. We use LoggerFactory to write to the standard output information about the events (an event log) but the The time it shows is not adequate.
This is the code (reduced and pseudo-encoded in some parts) of my main class:
package com.micompania.midepartamento.miproyecto
import org.slf4j.LoggerFactory
// otros imports
@SpringBootApplication
// otras anotaciones
open class miApplication {
companion object {
// algunas cosas por aquí
@Throws(IOException::class)
@JvmStatic
fun main(args: Array<String>) {
val log = LoggerFactory.getLogger(miApplication::class.java)
log.info("Arrancando ${miApplication::class.simpleName} ...")
// más cosas por acá
SpringApplication.run(miApplication::class.java, *args)
}
}
}
This works without problems, and in the standard output I see something like:
2018-01-31 11: 22: 32.542 [main] INFO com.micompania.midepartamento.miproyecto.miApplication - Starting MiApplication ...
Which is correct. But there is a problem: the time that appears is the local time of the machine in which the project runs, and to avoid confusion we want all hours to be in UTC. Is there any way to tell the logger to use the UTC time zone? What would it be like?