Using a different log file?


I need to display logs from go-admin in JSON format. The current format looks something like this:

2021-11-01T07:15:48.621+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize database connections
2021-11-01T07:16:27.962+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize database connections
2021-11-01T07:16:28.080+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize configuration
2021-11-01T07:16:28.091+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize navigation buttons
2021-11-01T07:16:28.091+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize plugins
2021-11-01T07:16:28.092+0100	e[34mINFOe[0m	engine/engine.go:402	=====> Initialize success🍺🍺

I’ve been trying different solutions I found online, but none of them work:

  1. As per this PR which was already merged into master, gin has gin.DebugPrintRouteFunc but adding a code like the following does nothing:
	gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
		logger.Info("This is a test")
		fmt.Println("This is another test")

This is the output I see:

  1. In the official documentation I see LoggerWithFormatter but again, adding some code like this does nothing:
r := gin.Default()
r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
	return "Test Format"

And this is what I see:

I’ve been able to make some of the logs print as JSON by using ginzap

I made my own logger package, adapting the original go-admin logger to use JSON encoding, and logger.GetLogger() returns the zap.Logger that has Encoding set to “json”. But I still have some of the go-admin logs in the standard text format:

Any idea how could I make ALL logs be shown in JSON format?

Thanks a lot!