Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to Log session id into Apache HTTP Server access log.

I need to maintain the session based logs.

Client may use web browser or their own client(like win32 application).

Here how to keep session id in the log file.

Any parameter is there like "%sessionID%" to log session ID ???

Thanks in advance.

share|improve this question
    
About the session ID, you need to add more information where it comes from. –  pkhamre Aug 16 '12 at 11:40
3  
@Satheesh - I have closed and/or merged your three recent questions as they are barely coherent, asking the same thing, and this one represents the best of a bad lot. Please take a moment to think through your problem, then edit this question to clearly explain what you are trying to accomplish, what steps you have taken to make that happen, what your expected results are, and what is actually happening in your environment. Configuration and log file excerpts are especially helpful. Flailing about repeatedly posting half-formed thoughts does not help us help you. Thanks. –  voretaq7 Aug 16 '12 at 22:54
    
Sorry, Am using Apache HTTP Server 2.0 on windows 7 & Accessing SVN Repository through the Apache service. I need to logging session Based logs. For example, Single user can use the repository from multiple instance of their own application(win 32 app for accessing SVN Repository). Here(IP & user is same but client application different)i need to differentiate those access.for each single client application i need to differentiate the logs.how can i ? –  Satheesh Aug 17 '12 at 3:32
    
Does stackoverflow.com/questions/6173180/… help? This shows the example with JSESSIONID, which is the Java servlet spec standard and also the default for web containers like WebSphere. –  user182592 Jul 22 '13 at 16:09
add comment

5 Answers

Insert %{sessionID}C into LogFormat directive.

%{Foobar}C  The contents of cookie Foobar in the request sent to the server. 
            Only version 0 cookies are fully supported.
share|improve this answer
    
I have given \"%{sessionID}C\" in LogFormat But in access.log It was empty ("_") Any Code is needed to add in httpd.conf & am using Apache HTTP Server 2.0. –  Satheesh Aug 16 '12 at 10:11
    
1. Post your request headers to make sure that Cookie includes sessionID. 2. Show us the LogFormat and CustomLog in the Apache configuration? –  quanta Aug 16 '12 at 10:24
    
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%{sessionID}C\" \"%r\" %>s %b" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent –  Satheesh Aug 16 '12 at 11:15
    
I don know how to add request header. Pls can anyone help to add request header –  Satheesh Aug 16 '12 at 11:37
add comment

Use RequestHeader from mod_headers to add a request header.

RequestHeader append MirrorID "mirror 12"

More information here: http://httpd.apache.org/docs/2.2/mod/mod_headers.html

share|improve this answer
    
Pls can any tell what are the code i need to add for getting session id. am new to apache..... I have Load module LoadModule headers_module modules/mod_headers.so in httpd.conf file –  Satheesh Aug 16 '12 at 11:49
add comment

Is the session id stored in cookie? If it is, you just need add %{cookie}i" into log format custom string.

share|improve this answer
add comment

HTTP is stateless - this means there is no session.

SSL maintains state across requests by a session identifier - but you didn't ask about that.

Applications maintain state across request using a session id which is propogated via various mechanisms - but again you didn't ask about that - nor did you provide any information about the operating system nor any logic tier.

I suspect you're talking about the logic tier session - it's usually quite easy to capture this - but you'd need to provide a lot more detail.

share|improve this answer
1  
And most likely post to StackOverflow as that is more in-line with what they deal with. (If it is logic tier based) –  Brent Pabst Aug 16 '12 at 12:37
    
I don know abt logic tier session... am using Apache Http Server 2.0 on windows 7 I need to log particular user from Login to logout. & the same user may login from another client. so That time i need to differentiate those two Logs. How its possible. Bcoz here Client IP & user name is same... the client application is only different.... & The Client may be web browser or any application(like win32 app) –  Satheesh Aug 16 '12 at 12:59
    
Pls give me idea to get i need. –  Satheesh Aug 16 '12 at 13:27
    
I don know abt logic tier session... am using Apache Http Server - then if you have no logic tier / no other components then you have no session / no session identifier –  symcbean Aug 17 '12 at 8:30
add comment

This is called 'clicktrack' logging. You need to use the Apache module mod_usertrack.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.