A
A
Artyom Varlamov2020-06-12 11:22:50
PHP
Artyom Varlamov, 2020-06-12 11:22:50

I am making a log parser for Apache in php, how to do it?

We need a parser that should do:

  1. Find the necessary errors from the logs, i.e. Fatal error, Parse error and output them via echo and say how many there are
  2. Find unnecessary errors and say how many of them
  3. And I have to say how many mistakes
  4. Must find how many unimportant errors and how many important and talk about it
  5. Should run once a day and parse several logs
  6. Should say the error itself and in which file it was (only an important error)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Sarvarov, 2020-06-12
@Frontend777

If there is no ready solution, you can:
1. First use glob() to find all the log files.
2. Then read each file in turn, for example, through fopen() and use regular expressions in a loop to select data according to some criteria.
We add all the information found through regular expressions to some array (and then display it somewhere), or, again, write it to the log.
To run once a day - use cron.

S
Stalker_RED, 2020-06-12
@Stalker_RED

This parser has long been invented. If you want, you can use ready-made, free of charge without SMS.
Scroll through a couple of articles on ELK and go.
https://mkdev.me/posts/vvedenie-v-elk-sobiraem-fil...
https://medium.com/@kirill.sereda/elk-elasticsearc...
there are also vids
https://www. youtube.com/results?search_query=elk+%...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question