Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP How To Save PHP Error Log To File In IIS

How To Save PHP Error Log To File In IIS

On production web sites, displaying all warnings or error messages are not recommended because this may reveal security information to end users, such as file paths on your Web server, your database schema or other information.

Saving all error log messages is a better idea. It’s very easy to turn this feature on if you’re on apache with ini_set function.

However, it’s quite complex if you’re running PHP on IIS, you need to have permission to modify the php.ini file and restart the IIS service.

Steps to save php error log message in IIS

  • 1. Open your php.ini file (ex: C:\WINDOWS\php.ini or C:\PHP\php.ini)
  • 2. Make sure log_errors directive is on to enable log errors into a log file. If not, change its value to On like this:
    log_errors = On

    log_errors = On

  • 3. Change error_log directive value with a full path of a file you wish to save the error messages. For example:
    error_log = "C:/PHP/error_log.txt"

    error_log = "C:/PHP/error_log.txt"

    Note: the file must be existed and can be write by everyone or the IUSR account.

  • 4. Restart the IIS Service

A piece of my php.ini related to the error log configuration:

; Print out errors (as a part of the output).  For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below).  Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = off
 
; Even when display_errors is on, errors that occur during PHP's startup
; sequence are not displayed.  It's strongly recommended to keep
; display_startup_errors off, except for when debugging.
display_startup_errors = Off
 
; Log errors into a log file (server-specific log, stderr, or error_log (below))
; As stated above, you're strongly advised to use error logging in place of
; error displaying on production web sites.
log_errors = On
 
error_log = "C:/PHP/error_log.txt"
 
; Set maximum length of log_errors. In error_log information about the source is
; added. The default is 1024 and 0 allows to not apply any maximum length at all.
log_errors_max_len = 1024

; Print out errors (as a part of the output). For production web sites, ; you're strongly encouraged to turn this feature off, and use error logging ; instead (see below). Keeping display_errors enabled on a production web site ; may reveal security information to end users, such as file paths on your Web ; server, your database schema or other information. display_errors = off ; Even when display_errors is on, errors that occur during PHP's startup ; sequence are not displayed. It's strongly recommended to keep ; display_startup_errors off, except for when debugging. display_startup_errors = Off ; Log errors into a log file (server-specific log, stderr, or error_log (below)) ; As stated above, you're strongly advised to use error logging in place of ; error displaying on production web sites. log_errors = On error_log = "C:/PHP/error_log.txt" ; Set maximum length of log_errors. In error_log information about the source is ; added. The default is 1024 and 0 allows to not apply any maximum length at all. log_errors_max_len = 1024

Aug 30, 2011Hoan Huynh
Function Remove All HTML Tags In PHPPHP Download Image Or File From URL
You Might Also Like:
  • PHP Error Log File Location
  • PHP Save String Content To File
  • PHP display all errors and warnings
  • Fatal error: Uncaught CurlException: 60: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed thrown
  • Save Video File With Custom Name In CamStudio Recorder
  • HTTP/ HTTPS Document, CGI-BIN And Access/ Error Logs On cPanel, Plesk And VirtualMin
  • ASP.Net C# Download Or Save Image File From URL
  • Changing hosts file in Windows
  • PHP Get Remote File Size And Content Type
  • Show Error Message On WordPress Custom Login Template Page
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

9 years ago PHPerror_log, log_errors, php.ini217
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
22,237 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
20,087 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,872 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,343 views
C# Read Json From URL And Parse/Deserialize Json
9,850 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Term Papers – Easy to Take Care of
  • How to Write Term Papers in Online Tutorials
  • How to Plan Writing an Essay
  • How to Apply For a Payday Loan With Bad Credit
  • Statistics For Sale – How To Compose One
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (123)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development