10

I have modified the configuration of rsyslogd to disable RSYSLOG_TraditionalFileFormat. But still the apache log /var/log/apache/error.log is displaying only second-precission.

Is there something else that needs to be configured?

jcollie
  • 621
  • 1
  • 5
  • 15
blueFast
  • 33,335
  • 48
  • 165
  • 292
  • 1
    Shouldn't be this question asked at ServerFault? – bahrep Mar 14 '13 at 09:43
  • mmm, you are probably right, but the tags are there! – blueFast Mar 14 '13 at 09:44
  • how can I move this to ServerFault? – blueFast Mar 14 '13 at 10:06
  • This is old, but I would like to point out something that is still valid today. I came across this question and an equivalent one at ServerFault (https://serverfault.com/questions/589768/is-there-a-way-to-log-apaches-request-time-in-milliseconds). Here, the question is said to belong to ServerFault (and I tend to agree). On Serverfault however, the equivalent question was closed because deemed off-topic (totally ridiculous!). Also, people tend to prefer SO because SF is not as much populated, so it gives lower chances of reply. I see this all the time. – cornuz Jul 09 '20 at 09:02

1 Answers1

9

At http://httpd.apache.org/docs/current/mod/mod_log_config.html you see differemt time formats including mili seconds Just change from

%t 
to 
%{%d/%b/%Y:%T}t-%{msec_frac}t for miliseconds
or
%{%d/%b/%Y:%T}t-%{usec_frac}t for microsecs

Example: 16/Mar/2013:22:44:34-634 16/Mar/2013:22:44:34-634200

Documenation apache

%t Time the request was received, in the format [18/Sep/2011:19:18:28 -0400]. The last number indicates the timezone offset from GMT

%{format}t The time, in the form given by format, which should be in an extended strftime(3) format (potentially localized). If the format starts with begin: (default) the time is taken at the beginning of the request processing. If it starts with end: it is the time when the log entry gets written, close to the end of the request processing. In addition to the formats supported by strftime(3), the following format tokens are supported:

sec number of seconds since the Epoch

msec number of milliseconds since the Epoch

usec number of microseconds since the Epoch

msec_frac millisecond fraction

usec_frac microsecond fraction

These tokens can not be combined with each other or strftime(3) formatting in the same format string. You can use multiple %{format}t tokens instead.

strftime(3) formatting http://man7.org/linux/man-pages/man3/strftime.3.html

Community
  • 1
  • 1
grzchr15
  • 283
  • 1
  • 6
  • 2
    Just a note - this doesn't work on 2.2 but only on apache 2.4+ – Jakov Sosic Jan 23 '15 at 18:06
  • Seems does not work in apache 2.4.10: ErrorLogFormat "%{%d/%b/%Y:%T}t-%{msec_frac}t [%-m:%l] [pid %P:tid %T] [client\ %a] %M% ,\ referer\ %{Referer}i" Output: Fri Feb 20 16:32:18 2015-2015-02-20 16:32:18 [core:notice] [pid 2162:tid 140307424573312] AH00094: Command line: '/usr/sbin/apache2' – Sirex Feb 20 '15 at 13:33