SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    198
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    where PHP Error Log file located in XAMPP localhost and live CENT OS 6 Server?

    where PHP Error Log file located in XAMPP localhost and live CENT OS 6 Server?

  2. #2
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    198
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Also files keep passwords eg databases etc must be outside public reach in web server? how access from my php code, a such file outside web root public dir? cent os 6, LAMPP....

  3. #3
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,397
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    There are some XAMPP error logs in apache > logs
    Unless you have a VPS I believe the only error logs you can view are the ones in the individual folders. You may to be able to download some logs above root in the logs folder, I think it depends on how the hosting is setup.

    To include a file above root you would use something like: include '/home/user/folder/file.php';
    You can setup a folder path in your php code with set_include_path but that never worked for me on a shared server.I have setup a folder in the php.ini file on my VPS which works well.

  4. #4
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,827
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Try this:
    PHP Code:

    echo '<br /><br />Error_log Stuff: <br />';

    $newErrorLog __DIR__  .'/ERROR_LOG_IS_NOW_IN_THIS_DIR.PHP';
    $newErrorLog getcwd() .'/ERROR_LOG_IS_NOW_IN_THIS_DIR.PHP';

    echo 
    '<br /><br />GET OLD: '// SET
        
    ini_get'error_log' ); // NO PARAMETERS

    echo '<br /><br />SET NEW and GET OLD: '// SET
        
    $oldErrorLog ini_set'error_log'$newErrorLog );

    echo 
    '<br /><br />SHOW NEW: '
        
    ini_get'error_log' ); // NO PARAMETERS

    echo '<br /><br />FORCE (and display) ERROR: '
        
    $forceError $divideByZero 0;

    if( 
    file_exists($newErrorLog) && filesize($newErrorLog) )
    {
      echo 
    '<br /><br />file_size(file_size($newErrorLog): ',   
          
    filesize($newErrorLog);

      
    $str file_get_contents$newErrorLog ) ;
      echo 
    '<br /><br />CONTENTS of $newErrorLog: <br />'
        
    nl2br$str );

    }

    die; 
    Output:

    Error_log Stuff:

    GET OLD: /opt/lampp/logs/php_error_log

    SET NEW and GET OLD: /opt/lampp/logs/php_error_log

    SHOW NEW: /opt/lampp/htdocs/localhost/sp-test/ERROR_LOG_IS_NOW_IN_THIS_DIR.PHP

    FORCE (and display) ERROR:
    Notice: Undefined variable: divideByZero in /opt/lampp/htdocs/localhost/sp-test/sp-test.php on line 22

    Warning: Division by zero in /opt/lampp/htdocs/localhost/sp-test/sp-test.php on line 22


    file_size(file_size($newErrorLog): 1256

    CONTENTS of $newErrorLog:
    {26-Apr-2014 17:50:19 Europe/Berlin} PHP Notice: Undefined variable: divideByZero in /opt/lampp/htdocs/localhost/sp-test/sp-test.php on line 22
    {26-Apr-2014 17:50:19 Europe/Berlin} PHP Warning: Division by zero in /opt/lampp/htdocs/localhost/sp-test/sp-test.php on line 22
    {26-Apr-2014 17:50:19 Europe/Berlin} PHP Fatal error: Call to undefined function file_size() in /opt/lampp/htdocs/localhost/sp-test/sp-test.php on line 24
    Last edited by John_Betong; Apr 26, 2014 at 09:00. Reason: formatting :*

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Have you set ip any virtual host. If so you can actually set the location of the error log...
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •