From d28237cd2fff1922f86fb7576c22625f067d24e7 Mon Sep 17 00:00:00 2001 From: Edward Rudd Date: Wed, 3 Mar 2004 22:11:42 +0000 Subject: Documentation conversion complete --- Documentation/manual.xml | 381 ++++++++++++++++++++++++----------------------- 1 file changed, 194 insertions(+), 187 deletions(-) diff --git a/Documentation/manual.xml b/Documentation/manual.xml index fe13daa..daafd69 100644 --- a/Documentation/manual.xml +++ b/Documentation/manual.xml @@ -1,6 +1,8 @@ - +eddie <at> omegaware <dot> com"> +]>
mod_log_sql Manual @@ -33,6 +35,11 @@ Edward Rudd + + 1.1 + 2004-03-02 + Updated for mod_log_sql v1.96 + 1.0 2004-01-22 @@ -44,7 +51,7 @@ Introduction Summary - This Apache module will permit you to log to a SQL database; it can log each access request as well as data associated with each request: cookies, notes, and inbound/outbound headers. Unlike logging to a flat text file -- which is standard in Apache -- a SQL-based log exhibits tremendous flexibility and power of data extraction. (See section [sub:why] in the FAQ for further discussion and examples of the advantages to SQL.) + This Apache module will permit you to log to a SQL database; it can log each access request as well as data associated with each request: cookies, notes, and inbound/outbound headers. Unlike logging to a flat text file -- which is standard in Apache -- a SQL-based log exhibits tremendous flexibility and power of data extraction. (See section in the FAQ for further discussion and examples of the advantages to SQL.) This module can either replace or happily coexist with mod_log_config, Apache's text file logging facility. In addition to being more configurable than the standard module, mod_log_sql is much more flexible. @@ -52,11 +59,11 @@ This project was formerly known as "mod_log_mysql." It was renamed "mod_log_sql" in order to reflect the project goal of database in-specificity. The module currently supports MySQL, but support for other database back-ends is underway. In order to save speed and overhead, links are kept alive in between queries. This module uses one dedicated SQL link per httpd child, opened by each child process when it is born. Among other things, this means that this module supports logging into only one MySQL server, and for now, also, only one SQL database. But that's a small tradeoff compared to the blinding speed of this module. Error reporting is robust throughout the module and will inform the administrator of database issues in the Apache ErrorLog for the server/virtual server. Virtual hosts are supported in the same manner they are in the regular logging modules. The administrator defines some basic 'global' directives in the main server config, then defines more specific 'local' directives inside each VirtualHost stanza. - A robust "preserve" capability has now been implemented. This permits the module to preserve any failed INSERT commands to a local file on its machine. In any situation that the database is unavailable -- e.g. the network fails or the database host is rebooted -- mod_log_sql will note this in the error log and begin appending its log entries to the preserve file (which is created with the user & group ID of the running Apache process, e.g. "nobody/nobody" on many Linux installations). When database availability returns, mod_log_sql seamlessly resumes logging to it. When convenient for the sysadmin, he/she can easily import the preserve file into the database because it is simply a series of SQL insert statements. + A robust "preserve" capability has now been implemented. This permits the module to preserve any failed INSERT commands to a local file on its machine. In any situation that the database is unavailable -- e.g. the network fails or the database host is rebooted -- mod_log_sql will note this in the error log and begin appending its log entries to the preserve file (which is created with the user and group ID of the running Apache process, e.g. "nobody/nobody" on many Linux installations). When database availability returns, mod_log_sql seamlessly resumes logging to it. When convenient for the sysadmin, he/she can easily import the preserve file into the database because it is simply a series of SQL insert statements. What gets logged by default? - All the data that would be contained in the "Combined Log Format" is logged by default, plus a little extra. Your best bet is to begin by accepting this default, then later customize the log configuration based on your needs. The documentation of the run-time directives includes a full explanation of what you can log, including examples -- see section [sec:ConfRef]. + All the data that would be contained in the "Combined Log Format" is logged by default, plus a little extra. Your best bet is to begin by accepting this default, then later customize the log configuration based on your needs. The documentation of the run-time directives includes a full explanation of what you can log, including examples -- see section . Miscellaneous Notes @@ -87,6 +94,7 @@ The MySQL routines and directives were added by Zeev Suraski <bourbon@netvision.net.il>. All changes from 1.06+ and the new documentation were added by Chris Powell chris <at> grubbybaby <dot> com. It seems that the module had fallen into the "un-maintained" category -- it had not been updated since 1998 -- so Chris adopted it as the new maintainer. In December of 2003, Edward Rudd eddie <at> omegaware <dot> com porting the module to Apache 2.0, cleaning up the code, converting the documentation to DocBook, optimizing the main logging loop, and added the much anticipated database abstraction layer. + As of February 2004, Chris Powell handed over maintenance of the module over to Edward Rudd. So you should contact Edward Rudd about the module from now on. @@ -113,9 +121,10 @@ Platform Specific Notes - This section is currently not applicable as the new autoconf setup should autodetect everything for your server..Win32 system, however, need to be updated.These installation documents assume a relatively modern GNU/Linux scenario. mod_log_sql has been ported to other platforms; following are notes on compiling the module for those platforms. - - <sub:Solaris>Solaris + This section is currently not applicable as the new autoconf setup should auto-detect everything for your server. The win32 compilation, however, is still on my todo list. This section needs to be overhauled so do not rely completely on any information presented in it. And anyone who compiles the mod_log_sql on these platforms, please report any issues/resolutions to compiling the module. + These installation documents assume a relatively modern GNU/Linux scenario. mod_log_sql has been ported to other platforms; following are notes on compiling the module for those platforms. + + Solaris The nanosleep() function used in mod_log_sql relies on linking aginst the librt library. Make the following alterations before proceeding: @@ -128,11 +137,11 @@ BSD - No notes are available at present, but they are desired. If you have successfully ported mod_log_sql to BSD, please contact [(chris@grubbybaby.com)||the maintaniner, Chris Powell] and help fill in this section. + No notes are available at present, but they are desired. If you have successfully ported mod_log_sql to BSD, please contact &MaintainerContact; and help fill in this section. Win32 - No notes are available at present, but they are desired. If you have successfully ported mod_log_sql to Win32, please contact [(chris@grubbybaby.com)||the maintaniner, Chris Powell] and help fill in this section. + No notes are available at present, but they are desired. If you have successfully ported mod_log_sql to Win32, please contact &MaintainerContact; and help fill in this section. OS X @@ -142,14 +151,15 @@ Digital Unix - Digital Unix, like Solaris, needs to be linked against librt; see section [sub:Solaris]. Here are further notes from a user successfully running the module on Digital Unix: + Digital Unix, like Solaris, needs to be linked against librt; see section . Here are further notes from a user successfully running the module on Digital Unix: Instead of trying to get the module to remember where the MySQL libraries were, I instead compiled apache with the information: LDFLAGS='-rpath /isp/mysql/lib/mysql' ./configure ... Everything worked as expected after that. (The error I got without this was "/sbin/loader: Fatal Error: cannot map libmysqlclient.so" ) Digital Unix (v4.0f, at least ) appears to follow the same requirements needed by Solaris, so simply adding librt to the module made it compile without errors. As for the warnings, here's the text: mod_log_sql.c: In function `extract_request_duration': mod_log_sql.c:292: warning: long int format, different type arg (arg 4) mod_log_sql.c: In function `extract_request_timestamp': mod_log_sql.c:497: warning: long int format, different type arg (arg 4) Poking around in the code, it looks like the compiler was complaining that what time() is returning doesn't play nicely with %ld by default. I just typecast them as (long)'s and the warnings went away ( not that the module wasn't working correctly without them ). The module works very well so far in testing... hasn't dropped a single log entry yet. My thanks to Jim Turner for permitting me to quote him here, and for being the first known user of mod_log_sql on Digital Unix Do I want a DSO or a static module - This section is no longer applicable, as the new autoconf setup only allows DSO with Apache 1.3 and 2.0.You need to know the answer to this question before you proceed. The answer is pretty straightforward: what have you done in the past? If you like all your Apache modules to be dynamic, then you should keep doing that. If you're more of an old-school type and prefer to compile the modules right into apache, do that. Both methods work equally well. + This section is no longer applicable, as the new autoconf setup only allows DSO with Apache 1.3 and 2.0. This section will be removed shortly. + You need to know the answer to this question before you proceed. The answer is pretty straightforward: what have you done in the past? If you like all your Apache modules to be dynamic, then you should keep doing that. If you're more of an old-school type and prefer to compile the modules right into apache, do that. Both methods work equally well. FWIW, the DSO method is more modern and increasing in popularity because apxs takes care of a lot of dirty little details for you. As you'll see below, the static-module method is a little more complex. @@ -254,12 +264,12 @@ AddModule mod_log_sql_ssl.c - - <sec:Configuration>Configuration - - <sub:PrepDb>Preparing MySQL for logging + + Configuration + + Preparing MySQL for logging You have to prepare the database to receive data from mod_log_sql, and set up run-time directives in httpd.conf to control how and what mod_log_sql logs. - This section will discuss how to get started with a basic configuration. Full documentation of all available run-time directives is available in section [sec:ConfRef]. + This section will discuss how to get started with a basic configuration. Full documentation of all available run-time directives is available in section . mod_log_sql can make its own tables on-the-fly, or you can pre-make the tables by hand. The advantage of letting the module make the tables is ease-of-use, but for raw performance you will want to pre-make the tables in order to save some overhead. In this basic setup we'll just let the module create tables for us. @@ -270,8 +280,8 @@ AddModule mod_log_sql_ssl.c Enter password: mysql> create database apachelogs; - - <part:CrTbl>If you want to hand-create the tables, run the enclosed 'create-tables' SQL script as follows ("create_tables.sql" needs to be in your current working directory). + + If you want to hand-create the tables, run the enclosed 'create-tables' SQL script as follows ("create_tables.sql" needs to be in your current working directory). mysql> use apachelogs Database changed mysql> source create_tables.sql @@ -281,11 +291,11 @@ mysql> source create_tables.sql mysql> grant insert,create on apachelogs.* to loguser@my.apachemachine.com identified by 'l0gger'; - You may be especially security-paranoid and want "loguser" to not have "create" capability within the "apachelogs" database. You can disable that privilege, but the cost is that you will not be able to use the module's on-the-fly table creation feature. If that cost is acceptable, hand-create the tables as described in step [part:CrTbl] and use the following GRANT statement instead of the one above: + You may be especially security-paranoid and want "loguser" to not have "create" capability within the "apachelogs" database. You can disable that privilege, but the cost is that you will not be able to use the module's on-the-fly table creation feature. If that cost is acceptable, hand-create the tables as described in step and use the following GRANT statement instead of the one above: mysql> grant insert on apachelogs.* to loguser@my.apachemachine.com identified by 'l0gger'; - - <step:EnaLog>Enable full logging of your MySQL daemon (at least temporarily for debugging purposes) if you don't do this already. Edit /etc/my.cnf and add the following line to your [mysqld] section: + + Enable full logging of your MySQL daemon (at least temporarily for debugging purposes) if you don't do this already. Edit /etc/my.cnf and add the following line to your [mysqld] section: log=/var/log/mysql-messages Then restart MySQL # /etc/rc.d/init.d/mysql restart @@ -332,7 +342,7 @@ LogSQLCreateTables on Visit your web site in a browser to trigger some hits, then confirm that the entries are being successfully logged: # mysql -hdbmachine.foo.com -umysqladmin -p -e "select * from access_log" apachelogs Enter password: - Several lines of output should follow, corresponding to your hits on the site. You now have basic functionality. Don't disable your regular Apache logs until you feel comfortable that the database is behaving as you'd like and that things are going well. If you do not see any entries in the access_log, please consult section [faq:NothingLogged] of the FAQ on how to debug and fix the situation. + Several lines of output should follow, corresponding to your hits on the site. You now have basic functionality. Don't disable your regular Apache logs until you feel comfortable that the database is behaving as you'd like and that things are going well. If you do not see any entries in the access_log, please consult section of the FAQ on how to debug and fix the situation. You can now activate the advanced features of mod_log_sql, which are described in the next section. @@ -344,7 +354,7 @@ Enter password: Instructing the module what to log The most basic directive for the module is LogSQLTransferLogFormat, which tells the module which information to send to the database; logging to the database will not take place without it. Place a LogSQLTransferLogFormat directive in the VirtualHost stanza of each virtual host that you want to activate. - After LogSQLTransferLogFormat you supply a string of characters that tell the module what information to log. In the configuration directive reference (section [sub:Frmat]) there is a table which clearly defines all the possible things to log. Let's say you want to log only the "request time," the "remote host," and the "request"; you'd use: + After LogSQLTransferLogFormat you supply a string of characters that tell the module what information to log. In the configuration directive reference (section ) there is a table which clearly defines all the possible things to log. Let's say you want to log only the "request time," the "remote host," and the "request"; you'd use: LogSQLTransferLogFormat hUS But a more appropriate string to use is LogSQLTransferLogFormat AbHhmRSsTUuv @@ -360,8 +370,8 @@ Enter password: - - <sub:Ignore>Instructing the module what NOT to log using filtering directives + + Instructing the module what NOT to log using filtering directives One "accept" and two "ignore" directives allow you to fine-tune what the module should not log. These are very handy for keeping your database as uncluttered as possible and keeping your statistics free of unneeded numbers. Think of each one as a gatekeeper. It is important to remember that each of these three directives is purely optional. mod_log_sql's default is to log everything. When a request comes in, the contents of LogSQLRequestAccept are evaluated first. This optional, "blanket" directive lets you specify that only certain things are to be accepted for logging, and everything else discarded. Because it is evaluated before LogSQLRequestIgnore and LogSQLRemhostIgnore it can halt logging before those two filtering directives "get their chance." @@ -428,8 +438,8 @@ LogSQLRequestIgnore statistics.html bluedot.jpg There are numerous benefits. The admin will not need to create new tables for every new VirtualHost. (Although the admin will still need to drop the tables of virtual hosts that are removed.) The admin will not need to set LogSQLTransferLogTable for each virtual host -- it will be configured automatically based on the host's name. Because each virtual host will log to its own segregated table, data about one virtual server will segregate from others; an admin can grant users access to the tables they need, and they will be unable to view data about another user's virtual host. In an ISP scenario the admin is likely to have a cluster of many front-end webservers logging to a back-end database. mod_log_sql has a feature that permits analysis of how well the web servers are loadbalancing: the LogSQLMachineID directive. The administrator uses this directive to assign a unique identifier to each machine in the web cluster, e.g. "LogSQLMachineID web01," "LogSQLMachineID web02," etc. Used in conjunction with the 'M' character in LogSQLTransferLogFormat, each entry in the SQL log will include the machine ID of the machine that created the entry. This permits the administrator to count the entries made by each particular machine and thereby analyze the front-end loadbalancing algorithm. - - <secMulTable>Logging many-to-one data in separate tables + + Logging many-to-one data in separate tables A given HTTP request can have a one-to-many relationship with certain kinds of data. For example, a single HTTP request can have 4 cookies, 3 headers and 5 "mod_gzip" notes associated with it. mod_log_sql is capable of logging these relationships due to the elegance of SQL relational data. You already have a single table containing access requests. One of the columns in that table is 'id' which is intended to contain the unique request ID supplied by the standard Apache module mod_unique_id -- all you need to do is compile in that module and employ the LogSQLTransferLogFormat character 'I'. Thereafter, each request gets a unique ID that can be thought of as a primary key within the database, useful for joining multiple tables. So let's envision several new tables: a notes table, a cookies table, and a table for inbound and outbound headers. @@ -593,8 +603,8 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg';It is wasteful and potentially confusing to permit this internal test data to clutter the database, and a solution to the problem is the proper use of the LogSQLMachineID directive. Assume a scenario where the production webservers have IDs like "web01," "web02," and so on -- and the test webservers have IDs like "test01," "test02," etc. Because entries in the log database are distinguished by their source machine, an administrator may purge unneeded test data from the access log as follows:delete from access_log where machine_id like 'test%'; - - <sub:DelayedIns>Optimizing for a busy database + + Optimizing for a busy database A busy MySQL database will have SELECT statements running concurrently with INSERT and UPDATE statements. A long-running SELECT can in certain circumstances block INSERTs and therefore block mod_log_sql. A workaround is to enable mod_log_sql for "delayed inserts," which are described as follows in the MySQL documentation. The DELAYED option for the INSERT statement is a MySQL-specific option that is very useful if you have clients that can't wait for the INSERT to complete. This is a common problem when you use MySQL for logging and you also periodically run SELECT and UPDATE statements that take a long time to complete. DELAYED was introduced in MySQL Version 3.22.15. It is a MySQL extension to ANSI SQL92. INSERT DELAYED only works with ISAM and MyISAM tables. Note that as MyISAM tables supports concurrent SELECT and INSERT, if there is no free blocks in the middle of the data file, you very seldom need to use INSERT DELAYED with MyISAM. @@ -610,13 +620,13 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; - The MySQL documentation concludes, "This means that you should only use INSERT DELAYED when you are really sure you need it!" Furthermore, the current state of error return from a failed INSERT DELAYED seems to be in flux, and may behave in unpredictable ways between different MySQL versions. See section [sub:DelayedInsFAQ] in the FAQ -- you have been warned. + The MySQL documentation concludes, "This means that you should only use INSERT DELAYED when you are really sure you need it!" Furthermore, the current state of error return from a failed INSERT DELAYED seems to be in flux, and may behave in unpredictable ways between different MySQL versions. See section in the FAQ -- you have been warned. If you are experiencing issues which could be solved by delayed inserts, then set LogSqlDelayedInserts On in the httpd.conf. All regular INSERT statements are now INSERT DELAYED, and you should see no more blocking of the module. - - <sec:ConfRef>Configuration directive reference + + Configuration Directive Reference It is imperative that you understand which directives are used only once in the main server config, and which are used inside VirtualHost stanzas and therefore multiple times within httpd.conf. The "context" listed with each entry informs you of this. @@ -739,16 +749,14 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLMachineID - - + LogSQLMachineID + machineID - - - - - + Example: LogSQLMachineID web01 + Context: main server config + If you have a farm of webservers then you may wish to know which particular machine made each entry; this is useful for analyzing your load-balancing methodology. LogSQLMachineID permits you to distinguish each machine's entries if you assign each machine its own LogSQLMachineID: for example, the first webserver gets ``LogSQLMachineID web01,'' the second gets ``LogSQLMachineID web02,'' etc. - + This is defined only once in the httpd.conf file. @@ -756,16 +764,27 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLMassVirtualHosting - - + LogSQLMassVirtualHosting + flag - - - - - + Example: LogSQLMassVirtualHosting On + Default: Off + Context: main server config + If you administer a site hosting many, many virtual hosts then this option will appeal to you. If you turn on LogSQLMassVirtualHosting then several things happen: + + + the on-the-fly table creation feature is activated automatically + + + the transfer log table name is dynamically set from the virtual host's name after stripping out SQL-unfriendly characters (example: a virtual host www.grubbybaby.com gets logged to table access_www_grubbybaby_com) + + + which, in turn, means that each virtual host logs to its own segregated table. Because there is no data shared between virtual servers you can grant your users access to the tables they need; they will be unable to view others' data. + + + This is a huge boost in convenience for sites with many virtual servers. Activating LogSQLMassVirtualHosting obviates the need to create every virtual server's table and provides more granular security possibilities. - + This is defined only once in the httpd.conf file. @@ -773,16 +792,15 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLNotesLogTable - - + LogSQLNotesLogTable + table-name - - - - - + Example: LogSQLNotesLogTable notes-log + Default: notes + Context: virtual_host + Defines which table is used for logging of notes. Working in conjunction with LogSQLWhichNotes, you can log many of each request's associated notes to a separate table. For meaningful data retrieval the notes table is keyed to the access table by the unique request ID supplied by the standard Apache module mod_unique_id. - + This table must be created (see create-tables.sql included in the package), or LogSQLCreateTables must be set to 'On'. @@ -790,84 +808,75 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQlPreserveFile - - + LogSQLPreserveFile + filename - - - - - - - - + Example: LogSQLPreserveFile offline-preserve + Default: /tmp/sql-preserve + Context: virtual host + mod_log_sql writes queries to this local preserve file in the event that it cannot reach the database, and thus ensures that your high-availability web frontend does not lose logs during a temporary database outage. This could happen for a number of reasons: the database goes offline, the network breaks, etc. You will not lose entries since the module has this backup. The file consists of a series of SQL statements that can be imported into your database at your convenience; furthermore, because the SQL queries contain the access timestamps you do not need to worry about out-of-order data after the import, which is done in a simple manner: + # mysql -uadminuser -p mydbname < /tmp/sql-preserve + If you do not define LogSQLPreserveFile then all virtual servers will log to the same default preserve file (/tmp/sql-preserve). You can redefine this on a virtual-host basis in order to segregate your preserve files if you desire. Note that segregation is not usually necessary, as the SQL statements that are written to the preserve file already distinguish between different virtual hosts if you include the 'v' character in your LogSQLTransferLogFormat directive. It is only necessary to segregate preserve-files by virualhost if you also segregate access logs by virtualhost. + The module will log to Apache's ErrorLog when it notices a database outage, and upon database return. You will therefore know when the preserve file is being used, although it is your responsibility to import the file. + The file does not need to be created in advance. It is safe to remove or rename the file without interrupting Apache, as the module closes the filehandle immediately after completing the write. The file is created with the user & group ID of the running Apache process (e.g. 'nobody' on many Linux distributions). LogSQLRemhostIgnore - - + LogSQLRemhostIgnore + hostname - - - - - - - - + Example: LogSQLRemhostIgnore localnet.com + Context: virtual host + Lists a series of strings that, if present in the REMOTE_HOST, will cause that request to not be logged. This directive is useful for cutting down on log clutter when you are certain that you want to ignore requests from certain hosts, such as your own internal network machines. See section for some tips for using this directive. + Each string is separated by a space, and no regular expressions or globbing are allowed. Each string is evaluated as a substring of the REMOTE_HOST using strstr(). The comparison is case sensitive. LogSQLRequestAccept - - + LogSQLRequestAccept + hostname - - - - - - - - + Example: LogSQLRequestAccept .html .php .jpg + Default: if not specified, all requests are 'accepted' + Context: virtual host + Lists a series of strings that, if present in the URI, will permit that request to be considered for logging (depending on additional filtering by the "ignore" directives). Any request that fails to match one of the LogSQLRequestAccept entries will be discarded. + This directive is useful for cutting down on log clutter when you are certain that you only want to log certain kinds of requests, and just blanket-ignore everything else. See section for some tips for using this directive. + Each string is separated by a space, and no regular expressions or globbing are allowed. Each string is evaluated as a substring of the URI using strstr(). The comparison is case sensitive. + This directive is completely optional. It is more general than LogSQLRequestIgnore and is evaluated before LogSQLRequestIgnore . If this directive is not used, all requests are accepted and passed on to the other filtering directives. Therefore, only use this directive if you have a specific reason to do so. LogSQLRequestIgnore - - + LogSQLRequestIgnore + hostname - - - - - - - - + Example: LogSQLRequestIgnore root.exe cmd.exe default.ida favicon.ico + Context: virtual host + Lists a series of strings that, if present in the URI, will cause that request to NOT be logged. This directive is useful for cutting down on log clutter when you are certain that you want to ignore requests for certain objects. See section for some tips for using this directive. + Each string is separated by a space, and no regular expressions or globbing are allowed. Each string is evaluated as a substring of the URI using strstr(). The comparison is case sensitive. LogSQLSocketFile - - + LogSQlSocketFile + filename - - - - - + Example: LogSQLSocketFile /tmp/mysql.sock + Default: /var/lib/mysql/mysql.sock + Context: main server config + At Apache runtime you can specify the MySQL socket file to use. Set this once in your main server config to override the default value. This value is irrelevant if your database resides on a separate machine. + mod_log_sql will automatically employ the socket for db communications if the database resides on the local host. If the db resides on a separate host the module will automatically use TCP/IP. This is a function of the MySQL API and is not user-configurable. - + This is defined only once in the httpd.conf file. @@ -875,50 +884,45 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLTCPPort - - + LogSQLTCPPort + port-number - - - - - + Example: LogSQLTCPPort 3309 + Default: 3306 + Context: main server config + Your database may listen on a different port than the default. If so, use this directive to instruct the module which port to use. This directive only applies if the database is on a different machine connected via TCP/IP. - + This is defined only once in the httpd.conf file. - - <sub:Frmat>LogSQLTransferLogFormat + + LogSQLTransferLogFormat - - + LogSQLTransferLogFormat + format-string - - - - - - - - + Example: LogSQLTransferLogFormat huSUTv + Default: AbHhmRSsTUuv + Context: virtual host + Each character in the format-string defines an attribute of the request that you wish to log. The default logs the information required to create Combined Log Format logs, plus several extras. Here is the full list of allowable keys, which sometimes resemble their Apache counterparts, but do not always: + TODO: Insert Log Format Types Table LogSQLTransferLogTable - - + LogSQLTransferLogTable + table-name - - - - - + Example: LogSQLTransferLogTable access_log_table + Context: virtual host + Defines which table is used for logging of Apache's transfers; this is analogous to Apache's TransferLog directive. table-name must be a valid table within the database defined in LogSQLDatabase. + This directive is not necessary if you declare LogSQLMassVirtualHosting On, since that directive activates dynamically-named tables. If you attempt to use LogSqlTransferlogTable at the same time a warning will be logged and it will be ignored, since LogSQLMassVirtualHosting takes priority. - + Requires unless LogSQLMassVirtualHosting is set to On @@ -926,16 +930,16 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLWhichCookie - - + LogSQLWhichCookie + cookiename - - - - - + Example; LogSQLWhichCookie Clicks + Context: virtual host + In HTTP, cookies have names to distinguish them from each other. Using mod_usertrack, for example, you can give your user-tracking cookies a name with the CookieName directive. + mod_log_sql allows you to log cookie information. LogSQL_WhichCookie tells mod_log_sql which cookie to log. This is necessary because you will usually be setting and receiving more than one cookie from a client. - + You must include a 'c' character in LogSQLTransferLogFormat for this directive to take effect. + although this was origintally intended for people using mod_usertrack to create user-tracking cookies, you are not restricted in any way. You can choose which cookie you wish to log to the database - any cookie at all - and it does not necessarily have to have anything to do with mod_usertrack. @@ -943,16 +947,14 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLWhichCookies - - + LogSQLWhichCookies + cookie-name - - - - - + Example: logSQLWhichCookies userlogin cookie1 cookie2 + Context: virtual host + Defines the list of cookies you would like logged. This works in conjunction with LogSQLCookieLogTable. This directive does not require any additional characters to be added to the LogSQLTransferLogFormat string. The feature is activated simply by including this directive, upon which you will begin populating the separate cookie table with data. - + The table must be created (see create-tables.sql, included in the package), or LogSQLCreateTables must be set to 'On'. @@ -960,16 +962,14 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLWhichHeadersIn - - + LogSQLWhichHeadersIn + header-name - - - - - + Example: LogSQLWhichHeadersIn UserAgent Accept-Encodeing Host + Context: virtual host + Defines the list of inbound headers you would like logged. This works in conjunction with LogSQLHeadersInLogTable. This directive does not require any additional characters to be added to the LogSQLTransferLogFormat string. The feature is activated simply by including this directive, upon which you will begin populating the separate inbound-headers table with data. - + The table must be created (see create-tables.sql, included in the package), or LogSQLCreateTables must be set to 'On'. @@ -977,16 +977,14 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLWhichHeadersOut - - + LogSQLWhichHeadersOut + header-name - - - - - + Example: LogSQLWhichHeadersOut Expires Content-Type Cache-Control + Context: virtual host + Defines the list of outbound headers you would like logged. This works in conjunction with LogSQLHeadersOutLogTable. This directive does not require any additional characters to be added to the LogSQLTransferLogFormat string. The feature is activated simply by including this directive, upon which you will begin populating the separate outbound-headers table with data. - + The table must be created (see create-tables.sql, included in the package), or LogSQLCreateTables must be set to 'On'. @@ -994,20 +992,29 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; LogSQLWhichNotes - - + LogSQLWhichNotes + note-name - - - - - + Example: LogSQLWhichNotes mod_gzip_result mod_gzip_ompression_ratio + Context: virtual host + Defines the list of notes you would like logged. This works in conjunction with LogSQLNotesLogTable. This directive does not require any additional characters to be added to the LogSQLTransferLogFormat string. The feature is activated simply by including this directive, upon which you will begin populating the separate notes table with data. - + The table must be created (see create-tables.sql, included in the package), or LogSQLCreateTables must be set to 'On'. + + DataBase Configuration + + + + + + + + + @@ -1015,7 +1022,7 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; General module questions - + Why log to an SQL database? @@ -1183,7 +1190,7 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; Who's using mod_log_sql? - Good question! It would be great to find out! If you are a production-level mod_log_sql user, please contact [(chris@grubbybaby.com)||the maintainer, Chris Powell] so that you can be mentioned here. + Good question! It would be great to find out! If you are a production-level mod_log_sql user, please contact &MaintainerContact; so that you can be mentioned here. @@ -1233,7 +1240,7 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; I have discovered a bug. Who can I contact? - Please contact [(chris@grubbybaby.com)||the maintainer], or post a message to the mod_log_sql mailing list. Your comments, suggestions, bugfixes, bug catches, and usage testimonials are always welcome. As free software, mod_log_sql is intended to be a community effort -- any code contributions or other ideas will be fully and openly credited, of course. + Please contact &MaintainerContact;, or post a message to the mod_log_sql mailing list. Your comments, suggestions, bugfixes, bug catches, and usage testimonials are always welcome. As free software, mod_log_sql is intended to be a community effort -- any code contributions or other ideas will be fully and openly credited, of course. @@ -1248,9 +1255,9 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; PHP and mod_log_sql can be configured to happily coexist. The solution is to configure PHP to link against the real MySQL libraries: recompile PHP using --with-mysql=/your/path. Apache will run properly once the modules are all using the same version of the MySQL libraries. - + - <faq:NothingLogged>Apache appears to start up fine, but nothing is getting logged in the database + Apache appears to start up fine, but nothing is getting logged in the database If you do not see any entries in the access_log, then something is preventing the inserts from happening. This could be caused by several things: @@ -1269,7 +1276,7 @@ where a.id=n.id and a.id='PPIDskBRH30AAGPtAsg'; It is improper to ask for help before you have followed these steps. - First examine the MySQL log that you established in step [step:EnaLog] of section [sub:PrepDb]. Ensure that the INSERT statements are not being rejected because of a malformed table name or other typographical error. By enabling that log, you instructed MySQL to log every connection and command it receives -- if you see no INSERT attempts in the log, the module isn't successfully connecting to the database. If you see nothing at all in the log -- not even a record of your administrative connection attempts, then you did not enable the log correctly. If you do see INSERT attempts but they are failing, the log should tell you why. + First examine the MySQL log that you established in step of section . Ensure that the INSERT statements are not being rejected because of a malformed table name or other typographical error. By enabling that log, you instructed MySQL to log every connection and command it receives -- if you see no INSERT attempts in the log, the module isn't successfully connecting to the database. If you see nothing at all in the log -- not even a record of your administrative connection attempts, then you did not enable the log correctly. If you do see INSERT attempts but they are failing, the log should tell you why. Second, confirm that your LogSQL* directives are all correct. Third, examine the Apache error logs for messages from mod_log_sql; the module will offer hints as to why it cannot connect, etc. The next thing to do is to change the LogLevel directive in the main server config as well as in each VirtualHost config: @@ -1422,9 +1429,9 @@ mysql> optimize table access_log; If you have exhausted all the tuning possibilities on your existing server, it is probably time you evaluated the benefits of clustering two or more webservers together in a load-balanced fashion. In fact, users of such a setup are mod_log_sql's target audience! - - - <sub:DelayedInsFAQ>What is the issue with activating delayed inserts? + + + What is the issue with activating delayed inserts? INSERT DELAYED is a specific syntax to MySQL and is not supported by any other database. Ergo, why is it needed, and what MySQL deficiency is it working around? INSERT DELAYED is a kluge. @@ -1442,7 +1449,7 @@ mysql> optimize table access_log; Instead of delayed inserts, you may wish to utilize InnoDB tables (instead of the standard MyISAM tables). InnoDB tables suppot row-level locking and are recommended for high-volume databases. - If after understanding these problems you still wish to enable delayed inserts, section [sub:DelayedIns] discusses how. + If after understanding these problems you still wish to enable delayed inserts, section discusses how. @@ -1467,9 +1474,9 @@ rm -f /var/log/httpd/templog See? Easy. - + - <sec:cookie>How can I log mod_usertrack cookies? + How can I log mod_usertrack cookies? A number of people like to log mod_usertrack cookies in their Apache TransferLog to aid in understanding their visitors' clickstreams. This is accomplished, for example, with a statement as follows: @@ -1525,8 +1532,8 @@ rm -f /var/log/httpd/templog As of version 1.17, you have a choice in how you want cookie logging handled. - If you are interested in logging only one cookie per request, follow the instructions in section [sec:cookie] above. That cookie will be logged to a column in the regular access_log table, and the actual cookie you want to log is specified with LogSQLWhichCookie. Don't forget to specify the 'c' character in LogSQLTransferLogFormat. - If, however, you need to log multiple cookies per request, you must employ the LogSQLWhichCookies (note the plural) directive. The cookies you specify will be logged to a separate table (as discussed in section [secMulTable]), and entries in that table will be linked to the regular access_log entries via the unique ID that is supplied by mod_unique_id. Without mod_unique_id the information will still be logged but you will be unable to correlate which cookies go with which access-requests. Furthermore, with LogSQLWhichCookies, you do not need to include the 'c' character in LogSQLTransferLogFormat. + If you are interested in logging only one cookie per request, follow the instructions in section above. That cookie will be logged to a column in the regular access_log table, and the actual cookie you want to log is specified with LogSQLWhichCookie. Don't forget to specify the 'c' character in LogSQLTransferLogFormat. + If, however, you need to log multiple cookies per request, you must employ the LogSQLWhichCookies (note the plural) directive. The cookies you specify will be logged to a separate table (as discussed in section ), and entries in that table will be linked to the regular access_log entries via the unique ID that is supplied by mod_unique_id. Without mod_unique_id the information will still be logged but you will be unable to correlate which cookies go with which access-requests. Furthermore, with LogSQLWhichCookies, you do not need to include the 'c' character in LogSQLTransferLogFormat. LogSQLWhichCookie and LogSQLWhichCookies can coexist without conflict because they operate on entireley different tables, but you're better off choosing the one you need. @@ -1549,7 +1556,7 @@ mysql> alter table access_log add column ssl_maxkeysize smallint unsigned; You also need to make sure you have the mod_log_sql_ssl module loaded as well. - The last three characters (Qqz) in the directive are the SSL ones; see section [sub:Frmat] in the directives documentation for details of the LogSQLTransferLogFormat directive. + The last three characters (Qqz) in the directive are the SSL ones; see section in the directives documentation for details of the LogSQLTransferLogFormat directive. Restart Apache, then perform some hits on your server. Then run the following select statement: mysql> select remote_host,request_uri,ssl_cipher,ssl_keysize,ssl_maxkeysize from access_log where ssl_cipher is not null;
-- cgit