Forum Discussion
JRahm
Oct 25, 2007Admin
Try this:
when CLIENT_ACCEPTED {
set secs [clock seconds]
set msec [clock clicks -milliseconds]
set base [expr { $secs * 1000 } ]
set fract [expr { $msec - $base }]
if { $fract >= 1000 } {
set diff [expr { $fract / 1000 }]
incr secs $diff
incr fract [expr { -1000 * $diff }]
}
log local0. "Timestamp with milliseconds is [clock format $secs -format {%H:%M:%S}].$fract"
}
My log entries with this code look like this:
Oct 25 08:16:47 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:47.399
Oct 25 08:16:49 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:49.575
Oct 25 08:16:49 tmm tmm[1541]: Rule logtime_rule : Timestamp with milliseconds is 08:16:49.582
Note that you really shouldn't use the clock command on production traffic unless your LTM is at least at version 9.2.
Modified from an example found here: http://wiki.tcl.tk/1035 Click here