W
W
WebforSelf2021-08-06 12:45:52
linux
WebforSelf, 2021-08-06 12:45:52

How to collect logs for a specific file for a period?

There is a server on Debian, it has access logs in nginx for every day

site.ru_access.log-20210618 in gz archive. Do I need to pull out the logs for a specific file when it was accessed?
Can this be done automatically somehow?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Slava Rozhnev, 2021-08-06
@WebforSelf

Use the following command:
grep 'needle' file.log >> result.txt

K
ky0, 2021-08-06
@ky0

If you want to be able to conveniently filter by any parameter - write not to files, but to a storage with the possibility of indexing, at least the same ELK. If this is an overkill and the need arises relatively rarely, write a script with a grep of the desired one.

D
Dmitry, 2021-08-06
@Tabletko

Script in bash

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question