-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zerolog interface not print logs #16
Labels
question
Further information is requested
Comments
Hey, Are the versions of zerolog the same? |
si @ziflex here is the verison
|
Could you show me how you set it up? Here is a workable snippet: package main
import (
"github.com/labstack/echo/v4"
"github.com/rs/zerolog"
"github.com/ziflex/lecho/v3"
"os"
)
func main() {
serv := echo.New()
logger := lecho.New(os.Stdout)
serv.Logger = logger
serv.Use(lecho.Middleware(lecho.Config{
Logger: logger,
}))
serv.GET("/", func(c echo.Context) error {
zerolog.Ctx(c.Request().Context()).Print("Zerolog interface🔥🔥🔥🔥🔥")
return c.String(200, "OK")
})
if err := serv.Start("0.0.0.0:8181"); err != nil {
panic(err)
}
} |
Oh I see i use this config to setup package main
import (
"github.com/labstack/echo/v4"
"github.com/rs/zerolog"
"github.com/ziflex/lecho/v3"
"os"
"github.com/labstack/gommon/log"
)
func main() {
serv := echo.New()
logger := lecho.New(os.Stdout,
lecho.WithLevel(log.INFO),
lecho.WithTimestamp(),
)
serv.Logger = logger
serv.Use(lecho.Middleware(lecho.Config{
Logger: logger,
}))
serv.GET("/", func(c echo.Context) error {
zerolog.Ctx(c.Request().Context()).Print("Zerolog interface🔥🔥🔥🔥🔥")
return c.String(200, "OK")
})
if err := serv.Start("0.0.0.0:8181"); err != nil {
panic(err)
}
} can you explain why? the result is {"time":"2022-03-25T09:37:54+07:00","message":"⇨ http server started on [::]:8181"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.006412,"latency_human":"6.412µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:37:56+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.025659,"latency_human":"25.659µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:37:58+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.007784,"latency_human":"7.784µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:37:58+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.007574,"latency_human":"7.574µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:37:59+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.007064,"latency_human":"7.064µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:38:01+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.007194,"latency_human":"7.194µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:38:01+07:00"}
{"level":"info","remote_ip":"::1","host":"localhost:8181","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36","status":200,"referer":"","latency":0.025539,"latency_human":"25.539µs","bytes_in":"0","bytes_out":"2","time":"2022-03-25T09:38:02+07:00"} |
What if you remove this line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In short, according to the title, when I use a zero log interface it can't print the logs, here the code snippet
and here is the log generated
why did it happen? I want to print the log using a zero log interface
The text was updated successfully, but these errors were encountered: