Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Add cookies in the Apache Log.

Posted on 2010-09-21
12
732 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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 125 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
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…

837 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