#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    30
    Rep Power
    1

    PHP custom loggin file and content output to browser


    I am facing a strange issue

    In case i switch on the error logging into a custom file by using following code

    ini_set("log_errors", 1);
    ini_set("error_log", "/opt/apache/logs/route.log");

    My PHP code stops sending content to browser

    i am using this to set content

    echo $content;

    Now if i dont set error_log , it works fine .. another thing is ..in case i set the log file, the php writes logs in file but do not send content to browser ..

    Any suggestions ?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,870
    Rep Power
    369
    when you say:
    "My PHP code stops sending content to browser "

    do you mean you get blank page? that usually means there is an error somewhere in your code.
  4. #3
  5. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,699
    Rep Power
    6351
    What errors are written when your script logs errors?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    30
    Rep Power
    1
    Originally Posted by paulh1983
    when you say:
    "My PHP code stops sending content to browser "

    do you mean you get blank page? that usually means there is an error somewhere in your code.
    Yes , i get blank page

    I use this to output content to browser
    echo $content;

    It works perfectly fine till the point I don't use following lines to output errors in log file

    ini_set("log_errors", 1);
    ini_set("error_log", "/opt/apache/logs/route.log");


    In case I comment second line like this .. every thing works fine , content sent to browser


    ini_set("log_errors", 1);
    #ini_set("error_log", "/opt/apache/logs/route.log");

    Before using this ini.set , i was putting error messgaes in error_log file of apache with this code

    error_log("Route.php ... qwHeaders Received .... $headerLine ");

    It was also working fine , but when i try to direct the logs in route.php by using ini.set .. things dont work , please note the logs are directed to route.log but the contents are not delivered to browser

    I want the logs to be directed to route.log and contents need to be directed to browser.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,699
    Rep Power
    6351
    Edit your php.ini directly.

    Also, once again: you claim you get errors in the logs right here:
    in case i set the log file, the php writes logs in file
    Are you GETTING ERRORS? If so, what are they?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    30
    Rep Power
    1
    Originally Posted by ManiacDan
    Edit your php.ini directly.

    Also, once again: you claim you get errors in the logs right here:
    Are you GETTING ERRORS? If so, what are they?
    I am sorry , i meant to say the logs I am writting to error_log is coming fine .. so there are no errors from apache or php .. the logs written to error_log are from my code which is fine .. Only problem is when i direct them to other file then error_log , using ini.set , it is an issue.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    30
    Rep Power
    1

    Apache crashing if i set error_log directive in php.ini file


    I am facing a problem where , my apache is crashing if i set error_log directive in php.ini file.. It works fine if the directive is commented out. I want to log in to a file from my php code that is directing me to set error_log directive.. Any have any idea.
  14. #8
  15. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,699
    Rep Power
    6351
    Are you doing it IN PHP.INI or are you still doing it within your actual PHP code. somefile.php and PHP.INI are completely separate things.

    Also, how do you know apache is crashing? I've asked you three times now for actual error messages. You cannot simply state "apache is crashing" and expect us to believe you if you don't have any ability to back up anything you're saying.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,699
    Rep Power
    6351
    Threads merged.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    30
    Rep Power
    1
    Originally Posted by ManiacDan
    Are you doing it IN PHP.INI or are you still doing it within your actual PHP code. somefile.php and PHP.INI are completely separate things.

    Also, how do you know apache is crashing? I've asked you three times now for actual error messages. You cannot simply state "apache is crashing" and expect us to believe you if you don't have any ability to back up anything you're saying.
    I am not getting any errors .. when i try to access the page apache crashes , which i confirms by checking the process status.. I dont see any error in error log..

    I am trying to put that in php.ini too , but again as soon as i put error_log directive , apache crashes without logging any error
  20. #11
  21. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,699
    Rep Power
    6351
    Apache has its own error log, and a system log. If apache is segfaulting, it may be installed wrong and you may fix it by uninstalling and reinstalling the whole stack.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo