[Solved] mod_accesslog buffers until lighttpd is killed
Added by LiveFreeAndRoam@gmail.com about 7 years ago
I'm using lighttpd/1.4.35 and trying to generate a custom accesslog. Unfortunately, the log message is only emitted when I kill the lighttpd process. How do I get it to emit the log message at the time the HTTP request/response occurs?
The process runs as:
/usr/local/bin/lighttpd -f /conf/lighttpd.conf -m /usr/local/lib
My config file is very simple:
server.modules = ( "mod_accesslog" ) server.errorlog = "/log/lighttpd_error.log" accesslog.filename = "/log/lighttpd_access.log" accesslog.format = "%h \"%r\" %>s %b (%O) TE:\"%{Transfer-Encoding}o\" CE:\"%{Content-Encoding}o\" <-- %I AE:\"%{Accept-Encoding}i\" TE:\"%{Transfer-Encoding}i\" CE:\"%{Content-Encoding}i\"" server.document-root = "/usr/local/www" mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png" ) ## SSL Engine $SERVER["socket"] == ":5443" { ssl.engine = "enable" ssl.cipher-list = "TLSv1+HIGH !SSLv2 !RC4 !aNULL !eNULL !3DES @STRENGTH" }
I use " tail -f /log/lighttpd_access.log ", I see nothing until I kill the lighttpd process. At which point, I see the expected output:
192.1.1.1 "GET /index.html HTTP/1.1" 200 484 (699) TE:"-" CE:"-" <-- 719 AE:"gzip, deflate, br" TE:"-" CE:"-" 192.2.1.76 "GET /index.html HTTP/1.1" 200 484 (699) TE:"-" CE:"-" <-- 441 AE:"gzip, deflate, br" TE:"-" CE:"-" 192.2.1.76 "GET /favicon.ico HTTP/1.1" 404 318 (452) TE:"-" CE:"-" <-- 411 AE:"gzip, deflate, br" TE:"-" CE:"-" 192.1.1.1 "GET /index.html HTTP/1.1" 200 484 (699) TE:"-" CE:"-" <-- 719 AE:"gzip, deflate, br" TE:"-" CE:"-"
Matt.
Replies (2)
RE: mod_accesslog buffers until lighttpd is killed - Added by LiveFreeAndRoam@gmail.com about 7 years ago
I found a workaround, by using syslog instead of a named file.
#accesslog.filename = "/store/log/lighttpd_access.log" accesslog.use-syslog = "enable" accesslog.syslog-level = 7
Now I can monitor the syslog with " tail -f /var/log/debug.log " and the formatted log appears in real-time.
It would be nicer to have a means to use non-buffered IO to any named file, but this workaround is fine for my purposes.
Matt.
RE: [Solved] mod_accesslog buffers until lighttpd is killed - Added by gstrauss about 7 years ago
Modern versions of lighttpd flush logs once a second.
If you're running lighttpd 1.4.35, you're probably also on an end-of-lifed operating system. Lots of self-inflicted problems.
If you want unbuffered access logs, then use either syslog, as you discovered, or use a piped logger.