Home >Backend Development >PHP Tutorial >The log has 5G, how to open it?

The log has 5G, how to open it?

WBOY
WBOYOriginal
2016-07-06 13:53:542339browse

I want to analyze the logs, but I have 5G. I don’t know what tool can open it. I tried two text splitters, but they can’t be opened, let alone counting splits. I’m looking for a method and a useful text splitter.
Thank you everyone for providing so many methods!

Reply content:

I want to analyze the logs, but I have 5G. I don’t know what tool can open it. I tried two text splitters, but they can’t be opened, let alone counting splits. I’m looking for a method and a useful text splitter.
Thank you everyone for providing so many methods!

What is this opening for? Do you want to see some of the content inside? The log is line by line. You can first use the head command to check the first few lines. If you feel it is not enough, then use tail to check the next few lines. If you want to extract something from the log, you can use the awk command to process it line by line. If you need to process a lot of logic, use python. file('log.log','r') in Python is a row iterator and takes up very little memory.
If you want to open it directly with a visual tool, the ultraEdit 64-bit mentioned earlier can do it

It is recommended to use EmEditor. The picture below is taken from the official website introduction.

The log has 5G, how to open it?

You can use fopen/while(!feof($fp))/fgets to traverse the file line by line to operate:

<code><?php
header('Content-Type: text/plain; charset=utf-8');
$file = __FILE__;
$fp = fopen($file, 'r');
$count = 0;
while ( !feof($fp) ) {
    $line = fgets($fp);
    //echo $count.': '.$line;
    $count++;
}
fclose($fp);</code>

Just use linux split

<code>split -b 100m your_file</code>

Try using ultraEdit 64-bit

Log analysis recommended awk

It’s not standardized enough..
Don’t you need to set an upper limit when processing logs, and archive them by classification and level? It’s 5G, which is very painful..

Try it with python generator

UltraEdit has tried to open log files larger than 2G, but not 7G.

less can view files!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn