<li><a href="#customlog">CustomLog</a></li>
+ <li><a href="#logexcludebytype">LogExcludeByType</a></li>
<li><a href="#logformat">LogFormat</a></li>
<li><a href="#transferlog">TransferLog</a></li>
</pre>
<hr />
+
+ <h2><a id="logexcludebytype" name="logexcludebytype">LogExcludeByType</a> directive</h2>
+
+ <p><a href="directive-dict.html#Syntax"
+ rel="Help"><strong>Syntax:</strong></a> LogExcludeByType
+ "<em>mimetype</em> <em>mimetype</em> <em>...</em>" [env=[!]<em>environment-variable</em>]<br />
+ <a href="directive-dict.html#Context"
+ rel="Help"><strong>Context:</strong></a> server config, virtual
+ host<br />
+ <a href="directive-dict.html#Status"
+ rel="Help"><strong>Status:</strong></a> Base<br />
+ <a href="directive-dict.html#Compatibility"
+ rel="Help"><strong>Compatibility:</strong></a> only
+ available in Apache 2.0.31 or later. <br />
+ <a href="directive-dict.html#Module"
+ rel="Help"><strong>Module:</strong></a> mod_log_config</p>
+
+ <p>The <code>LogExcludeByType</code> directive is used to not log requests
+ of certain types of files. for example, you may not want to log requests for
+ all the gif images on your site</p>
+
+ <p>The first argument, which specifies the mime types to ignore. These values
+ are space seperated and are in the simliar to image/gif. (To figure out what mime
+ type a certain file is, try looking at the request headers it returns where you request it)
+
+ <p>The third argument is optional and allows the decision on
+ whether or not to log a particular request to be based on the
+ presence or absence of a particular variable in the server
+ environment. If the specified <a href="../env.html">environment
+ variable</a> is set for the request (or is not set, in the case
+ of a '<code>env=!<em>name</em></code>' clause), then the
+ request will be logged.</p>
+
+ <hr />
+
<h2><a id="logformat" name="logformat">LogFormat</a>
directive</h2>
<!--%plaintext <?INDEX {\tt LogFormat} directive> -->
apr_array_header_t *config_logs;
apr_array_header_t *server_config_logs;
apr_table_t *formats;
+ const char *excluded_types_env_var;
+ apr_hash_t *excluded_types;
} multi_log_state;
/*
config_log_state *clsarray;
int i;
+ /* do we want to exclude this request */
+ if ( mls->excluded_types ) {
+ char *found = apr_hash_get(mls->excluded_types ,r->content_type,APR_HASH_KEY_STRING );
+ if ( found ) {
+ if ( mls->excluded_types_env_var ) {
+ if (mls->excluded_types_env_var[0] == '!' ) {
+ /* if it is set, then ignore the line */
+ if ( apr_table_get( r->subprocess_env ,&(mls->excluded_types_env_var[1])) ) {
+ return OK;
+ }
+ }
+ else {
+ /* if it isn't set, then ignore the line */
+ if ( apr_table_get(r->subprocess_env ,mls->excluded_types_env_var) == NULL ) {
+ return OK;
+ }
+ }
+ }
+ else {
+ /* no env var, so just ignore the request */
+ return OK;
+ }
+ }
+ }
/*
* Log this transaction..
*/
mls->default_format = NULL;
mls->server_config_logs = NULL;
mls->formats = apr_table_make(p, 4);
+ mls->excluded_types = NULL;
+ mls->excluded_types_env_var = NULL;
apr_table_setn(mls->formats, "CLF", DEFAULT_LOG_FORMAT);
return mls;
}
add->formats = apr_table_overlay(p, base->formats, add->formats);
+ if ( base->excluded_types && add->excluded_types ) {
+ add->excluded_types = apr_hash_overlay(p,add->excluded_types ,base->excluded_types );
+ }
+ else {
+ if ( base->excluded_types ) {
+ add->excluded_types = apr_hash_copy(p,base->excluded_types );
+ }
+ /* only add exclusions are possibly present, so nothing to do */
+ }
+ /* don't need to check excluded_types_env_var, we just take the override one if its there */
+
return add;
}
return add_custom_log(cmd, dummy, fn, "%{Cookie}n \"%r\" %t", NULL);
}
+static const char *set_exclude_by_type( cmd_parms *cmd, void *dummy,
+ const char*word1, const char*word2 )
+{
+ multi_log_state *mls = ap_get_module_config(cmd->server->module_config,
+ &log_config_module);
+ char *state;
+ char *exclusions;
+ char *excluded_type;
+
+
+ if (word2 != NULL) {
+ if (strncasecmp(word2, "env=", 4) != 0) {
+ return "error in condition clause, it should read env=XXX";
+ }
+ if ((word2[4] == '\0')
+ || ((word2[4] == '!') && (word2[5] == '\0'))) {
+ return "missing environment variable name";
+ }
+ mls->excluded_types_env_var= apr_pstrdup(cmd->pool, &word2[4]);
+ }
+ else {
+ mls->excluded_types_env_var=NULL;
+ }
+ /* if the first parameter is a empty string, then we do nothing */
+ mls->excluded_types = apr_hash_make(cmd->pool);
+ exclusions = apr_pstrdup(cmd->pool, word1);
+ excluded_type = apr_strtok(exclusions," ",&state);
+ while ( excluded_type ) {
+ /* it doesn't matter what we set */
+ apr_hash_set(mls->excluded_types, excluded_type,APR_HASH_KEY_STRING,"1");
+ excluded_type = apr_strtok(NULL," ",&state);
+ }
+ return NULL;
+}
+
static const command_rec config_log_cmds[] =
{
AP_INIT_TAKE23("CustomLog", add_custom_log, NULL, RSRC_CONF,
"a log format string (see docs) and an optional format name"),
AP_INIT_TAKE1("CookieLog", set_cookie_log, NULL, RSRC_CONF,
"the filename of the cookie log"),
+AP_INIT_TAKE12("LogExcludeByType",set_exclude_by_type, NULL, RSRC_CONF,
+ "a space-separated list of mime types to exclude from logging"),
{NULL}
};