3 ms·
One reason I do not like Nginx that much
# From serverfault - question about more precise timestamps in logs like milliseconds
# The only answer below
There are 2 ways to achieve this. The first one is dirty and I wont recommend it - it's the fastest way though:
if ($msec ~ "(.)\.(.)") {
set $epoch_millis = "$1$2"
}
This is much cleaner but requires lua:
set_by_lua_block $epoch_millis { return string.gsub(ngx.var.msec, "%.", "") }
then just log $epoch_millis
P.S. I am (the poster) from Russia but I regret editing Nginx configs almost every day...
- nodex-alex 8y agoSo you want to write a slower piece of code because it looks cleaner? That's about the dubmest thing I've ever heard, the chances are that you or nobody else will see the code so who cares? If it bothers you that much just document the code line