<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Logging_and_troubleshooting</id>
	<title>Logging and troubleshooting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Logging_and_troubleshooting"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Logging_and_troubleshooting&amp;action=history"/>
	<updated>2026-05-13T09:38:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Logging_and_troubleshooting&amp;diff=23960&amp;oldid=prev</id>
		<title>Cesar Chew at 17:48, 24 November 2014</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Logging_and_troubleshooting&amp;diff=23960&amp;oldid=prev"/>
		<updated>2014-11-24T17:48:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|Apache|07}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;slideshow style=&amp;quot;nobleprog&amp;quot; headingmark=&amp;quot;⌘&amp;quot; incmark=&amp;quot;…&amp;quot; scaled=&amp;quot;true&amp;quot; font=&amp;quot;Trebuchet MS&amp;quot; &amp;gt;&lt;br /&gt;
;title: Logging and troubleshooting&lt;br /&gt;
;author: Sam Bashton (NobleProg Ltd)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/slideshow&amp;gt;&lt;br /&gt;
=== Apache log format ⌘===&lt;br /&gt;
* **common** log format - NCSA format&lt;br /&gt;
* Understood by many (old) programs&lt;br /&gt;
:* AWstats&lt;br /&gt;
:* Webalizer&lt;br /&gt;
 &lt;br /&gt;
 127.0.0.1 user-identifier frank [10/Oct/2000:13:55:36 +0100] &amp;quot;GET /apache_pb.gif HTTP/1.0&amp;quot; 200 2326&lt;br /&gt;
&lt;br /&gt;
:* A &amp;quot;-&amp;quot; in a field indicates missing data.&lt;br /&gt;
:* 127.0.0.1 is the IP address of the client (remote host) which made the request to the server.&lt;br /&gt;
:* user-identifier is the RFC 1413 identity of the client.&lt;br /&gt;
:* frank is the username of the person requesting the document.&lt;br /&gt;
:* [10/Oct/2000:13:55:36 +0100] is the date, time, and time zone when the server finished processing the request, by default in strftime format %d/%b/%Y:%H:%M:%S %z&lt;br /&gt;
:* &amp;quot;GET /apache_pb.gif HTTP/1.0&amp;quot; is the request line from the client.&lt;br /&gt;
:* 200 is the HTTP status code returned to the client.&lt;br /&gt;
:* 2326 is the size of the object returned to the client, measured in bytes.&lt;br /&gt;
&lt;br /&gt;
=== CustomLog format ⌘===&lt;br /&gt;
* Commonly you would set your own log format&lt;br /&gt;
* Two parts to this:&lt;br /&gt;
:* Define the format&lt;br /&gt;
:* Set it as the log output type&lt;br /&gt;
&lt;br /&gt;
=== Example: `vhost_combined` format ⌘===&lt;br /&gt;
 LogFormat &amp;quot;%v:%p %h %l %u %t \&amp;quot;%r\&amp;quot; %&amp;gt;s %O \&amp;quot;%{Referer}i\&amp;quot; \&amp;quot;%{User-Agent}i\&amp;quot;&amp;quot; vhost_combined`&lt;br /&gt;
&lt;br /&gt;
* `%v` - Canonical ServerName (VirtualHost)&lt;br /&gt;
* `%p` - Server Port&lt;br /&gt;
* `%h` - Remote Host.  Use `%{X-Forwarded-For}i` if behind a proxy&lt;br /&gt;
* `%l` - Remote log name (ignore, identd, unused)&lt;br /&gt;
* `%u` - User name&lt;br /&gt;
* `%r` - Request&lt;br /&gt;
* `%&amp;gt;s` - Final status (eg 200, 404)&lt;br /&gt;
* `%0` - requested server name&lt;br /&gt;
* `%{Referer}i` - URL user visited to find this page&lt;br /&gt;
* `%{User-Agent}i` - web browser of the remote user&lt;br /&gt;
&lt;br /&gt;
=== Other log variables ⌘===&lt;br /&gt;
* See http://httpd.apache.org/docs/current/mod/mod_log_config.html&lt;br /&gt;
&lt;br /&gt;
=== Setting the Log Format ⌘===&lt;br /&gt;
  CustomLog /var/log/httpd/example-access.log vhost_combined&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting Apache: Backtrace ⌘===&lt;br /&gt;
:* Apache crashing?&lt;br /&gt;
:* Messages like this in the log:&lt;br /&gt;
&lt;br /&gt;
 child pid 1256 exit signal Segmentation fault (11)&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a coredump ⌘===&lt;br /&gt;
:* On &amp;gt;=EL6 - /var/spool/abrt will contain it&lt;br /&gt;
:* On &amp;lt;= EL5 - enable CoreDump directive in Apache config&lt;br /&gt;
&lt;br /&gt;
 CoreDumpDirectory /var/spool/coredumps&lt;br /&gt;
&lt;br /&gt;
* Create `/var/spool/coredumps`&lt;br /&gt;
* Wait for it to crash again&lt;br /&gt;
&lt;br /&gt;
=== Backtracing the coredump ⌘===&lt;br /&gt;
* We can use gdb to obtain a backtrace&lt;br /&gt;
* Should at least give us some hints as to what it going wrong&lt;br /&gt;
:* and/or a file to give to Red Hat support&lt;br /&gt;
* We need to enable debugnfo yum repo which contains debugging symbols&lt;br /&gt;
:* Can be done via RHN or from the command line:&lt;br /&gt;
 rhn-channel -a -c rhel-`uname -i`-Server-5-debuginfo -u &amp;lt;Your RHN ID&amp;gt; -p &amp;lt;Your Password&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Also need to install the `yum-utils` package if not installed&lt;br /&gt;
&lt;br /&gt;
=== Performing the backtrace ===&lt;br /&gt;
* All relevant debugging symbols need to be installed&lt;br /&gt;
* gdb will tell you which ones need to be installed and how&lt;br /&gt;
* Run `gdb /usr/bin/httpd corefile`&lt;br /&gt;
* At the gdb prompt, type `bt`&lt;br /&gt;
&lt;br /&gt;
=== Sample gdb output: ⌘===&lt;br /&gt;
 (gdb) bt&lt;br /&gt;
 #0  0x080ca21b in _efree (ptr=0xbfffdb9b) at zend_alloc.c:240&lt;br /&gt;
 #1  0x080d691a in _zval_dtor (zvalue=0x8186b94) at zend_variables.c:44&lt;br /&gt;
 #2  0x080cfab3 in _zval_ptr_dtor (zval_ptr=0xbfffdbfc) at zend_execute_API.c:274&lt;br /&gt;
 #3  0x080f1cc4 in execute (op_array=0x816c670) at ./zend_execute.c:1605&lt;br /&gt;
 #4  0x080f1e06 in execute (op_array=0x816c530) at ./zend_execute.c:1638&lt;br /&gt;
 #5  0x080f1e06 in execute (op_array=0x816c278) at ./zend_execute.c:1638&lt;br /&gt;
 #6  0x080f1e06 in execute (op_array=0x8166eec) at ./zend_execute.c:1638&lt;br /&gt;
 #7  0x080d7b93 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at zend.c:810&lt;br /&gt;
 #8  0x0805ea75 in php_execute_script (primary_file=0xbffff650) at main.c:1310&lt;br /&gt;
 #9  0x0805cdb3 in main (argc=2, argv=0xbffff6fc) at cgi_main.c:753&lt;br /&gt;
 #10 0x400c91be in __libc_start_main (main=0x805c580 &lt;br /&gt;
 , argc=2, ubp_av=0xbffff6fc,&lt;br /&gt;
               init=0x805b080 &amp;lt;_init&amp;gt;, fini=0x80f67b4 &amp;lt;_fini&amp;gt;, rtld_fini=0x4000ddd0 &amp;lt;_dl_fini&amp;gt;,&lt;br /&gt;
               stack_end=0xbffff6ec) at ../sysdeps/generic/libc-start.c:129&lt;br /&gt;
 (gdb) frame 3&lt;br /&gt;
 #3  0x080f1cc4 in execute (op_array=0x816c670) at ./zend_execute.c:1605&lt;br /&gt;
 (gdb) print (char *)(executor_globals.function_state_ptr-&amp;gt;function)-&amp;gt;common.function_name&lt;br /&gt;
 $14 = 0x80fa6fa &amp;quot;pg_result_error&amp;quot;&lt;br /&gt;
 (gdb) print (char *)executor_globals.active_op_array-&amp;gt;function_name&lt;br /&gt;
 $15 = 0x816cfc4 &amp;quot;result_error&amp;quot;&lt;br /&gt;
 (gdb) print (char *)executor_globals.active_op_array-&amp;gt;filename&lt;br /&gt;
 $16 = 0x816afbc &amp;quot;/home/yohgaki/php/DEV/segfault.php&amp;quot;&lt;br /&gt;
 (gdb) &lt;br /&gt;
&lt;br /&gt;
* In this session, frame 3 is the last execute() call. The frame 3 command moves the current working stack to the proper frame.  &lt;br /&gt;
* In the sample gdb session, the pg_result_error() call is causing the segfault.&lt;/div&gt;</summary>
		<author><name>Cesar Chew</name></author>
	</entry>
</feed>