?
Solved

Add cookies in the Apache Log.

Posted on 2010-09-21
12
Medium Priority
?
757 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
[X]
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
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
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

752 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