Tuesday, 15 September 2015

regex - Custom Apache log file based on regular expression -



regex - Custom Apache log file based on regular expression -

i'm working on project, require special centos apache server setup. entries must pre-processed , sorted conditions , placed separate log files.

take these apache requests, instance:

http://logs.domain.com/log.gif?obj=test01|id=886655774|e=via|r=4524925241 http://logs.domain.com/log.gif?obj=test01|id=886655774|e=via|r=9746354562

for every entry, apache must search through request url. if finds "obj"-parameter, log name must created. in case, 1 file name "test01" created (if doesn't exist), containing these 2 entries.

i found among others: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html , assume, done kind of regex, still need farther force in right direction, please.

apache not back upwards sort of fine-grain log directing. however, write log reader reads apache logs , subsequently writes appropriate sub-logs.

there 3 things aware of:

apache log writes not atomic , apache uses no file locking. means programme reading log cannot guarunteed lastly log entry complete, , there no reliable real-time way tell if apache writing log.

the error logs can have multiple lines, , first match pattern. additionally, many cgi scripts write lines without appropriate prefix. hard command unless write code yourself. access log, @ least, pretty standard 1 line = 1 entry prefix though.

the reader must maintain track of current file atime, ctime, , size somewhere on disk, if it's stopped , restarted, can go on left off. additionally, must correctly handle switch-over when apache begins writing new log. (the old log renamed.)

regex apache mod-rewrite logging

No comments:

Post a Comment