E
E
emizerov2021-01-14 17:57:02
go
emizerov, 2021-01-14 17:57:02

Do I need to log the request to the server?

This may seem like a trivial question.
Does the Go server need to log the fact of the request?
If yes, then why?

Let's use Django as an example.
INFO "GET / HTTP/1.1" 200 6698
POST "POST /create/ HTTP/1.1" 200 6632

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman Kitaev, 2021-01-14
@emizerov

go is usually hidden behind a reverse proxy (like nginx). Nginx has an access log, so logging it on the service side is redundant.
And why is this needed - for incident investigations, for compiling statistics on logs. For example, the number of requests per day / hour / minute / second - see load bursts, distribution by response codes, popular URLs, user IPs to see botnets from China. Tons of applications.

A
aleks-th, 2021-01-14
@aleks-th

As long as it doesn't break, it's not necessary.
And when they break it, or something stops working, you will think - what idiot turned off the logs.

S
Stanislav Bodrov, 2021-01-14
@jenki

In addition to fixing the request, you also need to write at least some informative data about the operation of the server (response time, some statuses of the response to the request). If there is a downlink or a base where they go for data, it is very desirable to fix the status of the connection or response.
It's just a good habit and the right habit. When you get into a serious company, where even before getting into the pre-prod service, they drive tests into the tail and mane, you will grab rays of goodness from QA or DevOps, or your application will simply be deployed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question