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.

I would like to enhance my logfile with an additional field containing the mime type. E.G.

127.0.0.1 - - [01/Mar/2012:20:49:36 +0100] "GET / HTTP/1.1" 200 255 [...] "text/html"
127.0.0.1 - - [01/Mar/2012:20:49:37 +0100] "GET /x.gif HTTP/1.1" 200 1022 [...] "image/gif"

I could not find a standard field for this feature.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can log any header field that is present in the response, like so: %{HEADER_NAME}i.

Refer to the Custom Log Formats documentation for details.

share|improve this answer
2  
I guess the header you would want would be Content-Type: so in CustomLog: "%{Content-Type}i". It does contain more than just the MIME type, however. Wrapped in quotes because the header can contain spaces. –  Ladadadada Mar 8 '12 at 10:13
1  
The "i" at the end of {HEADER_NAME} is wrong, but I figured out that I need to replace it with an "o". (like "incoming" and "outgoing") –  mawimawi Mar 8 '12 at 11:39
    
Ah, excellent, sorry about that. –  adaptr Mar 8 '12 at 12:56
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.