?
Solved

Add cookies in the Apache Log.

Posted on 2010-09-21
12
Medium Priority
?
767 Views
Last Modified: 2012-05-10
I would like to have a cookie coming from my client or a new value in there place in my log file.

I'm using a Apache2 and mod-perl.

0
Comment
Question by:oleber
  • 6
  • 5
12 Comments
 
LVL 10

Author Comment

by:oleber
ID: 33725246
The question is:

how do I do it?
0
 
LVL 10

Author Comment

by:oleber
ID: 33725269
in the access and log error
0
 
LVL 57

Expert Comment

by:giltjr
ID: 33733222
Cookies should only come from a browser if you place them in there.

Why do you want cookies to show up in your log if you are the one placing them there?

I'll double check, but I'm not aware of anyway that you can do this.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Author Comment

by:oleber
ID: 33733356
I don't care why, just how.

I want to be able of grouping every write to the log files. Since the code is all done, t is to expansive to go to every log line and add one identifier.

For now, my best solution was to do a wrapper around the $r in Perl and rewrite the log stuff. Is there something better, that means generic and easy to implement?
0
 
LVL 57

Expert Comment

by:giltjr
ID: 33733576
I was trying to figure out why you want to do this to see if there is another possible option than filling the log with cookies.

According to:

http://www.wellho.net/mouth/1761_Logging-Cookies-with-the-Apache-httpd-web-server.html

You can use "%{Cookie}i"
0
 
LVL 10

Author Comment

by:oleber
ID: 33733667
That works correctly over the access log.

Now the problem is the error log.

How do I set that value in there?

Note: Don't need to come from a cookie, since all my calls pass from a common place.
0
 
LVL 57

Expert Comment

by:giltjr
ID: 33733871
I'm looking for error log stuff.

You can also use:

%{Foobar}C

Where Foobar is the name of the specific cookie you want to log.

Ref: http://httpd.apache.org/docs/current/mod/mod_log_config.html#formats
0
 
LVL 57

Accepted Solution

by:
giltjr earned 375 total points
ID: 33733889
If you read the "Modifiers" section in the above reference you will find:

Particular items can be restricted to print only for responses with specific HTTP status codes by placing a comma-separated list of status codes immediately following the "%". For example, "%400,501{User-agent}i" logs User-agent on 400 errors and 501 errors only. For other status codes, the literal string "-" will be logged. The status code list may be preceded by a "!" to indicate negation: "%!200,304,302{Referer}i" logs Referer  on all requests that do not return one of the three specified codes.

So if you have specific errors, you want to log the cookie values on, you should be able to do that.  I am assuming that they appear in the error log.
0
 
LVL 10

Author Comment

by:oleber
ID: 33735762
OK, I am able of configure this over the access_log, but I'm not able of configure over the error log.

Do you have any idea how to do it?
0
 
LVL 57

Expert Comment

by:giltjr
ID: 33736260
I can seem to find a way customize what is sent to the error log.
0
 
LVL 10

Author Closing Comment

by:oleber
ID: 33763497
seems that just in the new version of apache this will be possible in the access log
0
 
LVL 62

Expert Comment

by:gheist
ID: 33768208
you can not customize error log.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question