Add Timestamps to Vapor Logs - How To?

Hi. I would like to update the default Vapor logs format to include a timestamp. Can anyone point at how to do it?

Thanks!

When you bootstrap the logger, you want to use this function and then initialise the logger with the timestamp fragment

3 Likes

Awesome, thanks! I replaced the default one with the following snippet and it worked:

let level = try Logger.Level.detect(from: &env)
LoggingSystem.bootstrap(fragment: timestampDefaultLoggerFragment(), console: Terminal(), level: level)