rotated gzipped files

Alex's Avatar

Alex

04 Mar, 2015 01:24 PM

Hello,
we have some files like:

access.log
access.log.1
access.log.1.gz

i cant open the gz ones. Is there any possibility to get them opened?

  1. Support Staff 1 Posted by potsky on 04 Mar, 2015 01:41 PM

    potsky's Avatar

    Hi Alex,

    no it is not possible out of the box.

    Why don't you change the log rotate configuration ? Just remove the compress parameter and you are ok !

  2. 2 Posted by Alex on 04 Mar, 2015 02:45 PM

    Alex's Avatar

    We now have built a quick and dirty fix for our needs ;-)

    File "LogParser.php"

    $new_file_path = $file_path;
    if((strlen($file_path) - 3) == strrpos($file_path, ".gz"))
    {

    $zd = gzopen($file_path, "r");
    $contents = gzread($zd, 100*1024*1024);
    gzclose($zd);
    #echo "length string read = " . strlen($contents) . "<br>";
    #echo $contents . "\n\n";
    $new_file_path = "/tmp/" . "pimp_tmp.log";
    file_put_contents($new_file_path, $contents);
    }
    #echo "NEW PATH $new_file_path" . "<br>";
    $fl = fopen( $new_file_path , "r" );
    if ($fl === false) {
    return '1';
    }

            $logs = array();
            $start = microtime( true );
            $regsearch = false;
            $found = false;
            $bytes = 0;
            $skip = 0;
            $error = 0;
            $abort = false;
            $file_lastline = '';
            $search_lastline = true;
            $buffer = array();

            /*
            |--------------------------------------------------------------------------
            | Last modification time and size for this log file
            |--------------------------------------------------------------------------
            |
            */
            if ( version_compare( PHP_VERSION , '5.3.0' ) >= 0 ) {
                $filem = new DateTime( );
                $filem->setTimestamp( filemtime( $new_file_path ) );
            } else {
                $filem = new DateTime( "@" . filemtime( $new_file_path ) );
            }
            if ( ! is_null( $tz ) ) {
                $filem->setTimezone( new DateTimeZone( $tz ) );
            }
            $filemu = $filem->format( 'U' );
            $filem = $filem->format( 'Y/m/d H:i:s' );
            $filesize = filesize( $new_file_path );

  3. Support Staff 3 Posted by potsky on 05 Mar, 2015 08:59 AM

    potsky's Avatar

    Dirty indeed :-)

    I will try to add this next week an publish a new version if possible. I will :

    • ensure gzip extension is loaded
    • try to load data in a streaming way (mandatory to parse big files)

    If it is not possible to load data from the end of the file to the beginning in a stream way, I will not include this feature.

  4. 4 Posted by Juan on 26 Sep, 2016 01:41 PM

    Juan's Avatar

    Is this already implemented?

  5. 5 Posted by Chelsey Stenhou... on 25 Nov, 2024 05:15 PM

    Chelsey Stenhouse's Avatar

    I saw that your pimpmylog.com website may be missing out on approximately a thousand visitors daily. Our AI powered traffic system is tailored to boost your site's visibility: https://ow.ly/V0j150Uaobz
    We're offering a free trial that includes four thousand targeted visitors to show the potential benefits. After the trial, we can supply up to 250K targeted visitors per month. This service could greatly enhance your website's reach and visitors.

  6. 6 Posted by Merry Morris on 05 Dec, 2024 05:56 PM

    Merry Morris's Avatar

    I noticed that your pimpmylog.com website could be missing out on approximately a thousand visitors daily. Our AI powered traffic system is tailored to boost your site's visibility: https://ow.ly/Zp3x50UaoaQ
    We're offering a free trial that includes four thousand targeted visitors to show the potential benefits. After the trial, we can supply up to a quarter million targeted visitors per month. This opportunity could greatly enhance your website's reach and traffic.

  7. 7 Posted by Saundra Stainfo... on 12 Jan, 2025 06:43 AM

    Saundra Stainforth's Avatar

    Get more leads for your pimpmylog.com website by using AI on Instagram. If you're looking to drive more traffic, generate leads, and grow your brand's reach, you can get more information and start a free trial here: https://shorten.ee/hMDo3

    This is an AI-powered Instagram growth service that:
    -Increases followers with targeted, high-quality audiences. -Boosts engagement through smart AI algorithms. -Targets users based on hashtags and accounts they follow. -Saves you time by automating tedious Instagram tasks.

    Our service focuses on real, organic growth—no bots, no fake followers. It’s perfect for brands like yours that want to turn Instagram into a lead generation powerhouse. Better yet, our service is provided on a month-by-month subscription basis so you can cancel any time you like. No contracts and a 7 day free trial.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac