Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase precision of apache log to include milliseconds

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?

like image 510
blueFast Avatar asked Mar 14 '13 09:03

blueFast


People also ask

How to change Apache access log format?

The CustomLog directive is what controls the location and format of the Apache access log file. This directive can be placed in the server configuration file ( /etc/apache2/apache2. conf ) or in your virtual host entry. Note that defining the same CustomLog directive in both files may cause problems.

What is custom log in Apache?

Base. Module: mod_log_config. The CustomLog directive is used to log requests to the server. A log format is specified, and the logging can optionally be made conditional on request characteristics using environment variables.

What is Apache log format?

Apache uses the Common Log Format (CLF) by default, but you can specify your own format string to change the fields included in each log. You can also use the CustomLog directive to change the location of the log file.

What is Apache log parser?

Apache reports extensive data about your website, server, and users, but extracting that data from logs is the trick. Parsing Apache logs convert the raw text produced by Apache into fields that can be indexed, searched, and analyzed.


1 Answers

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

like image 86
grzchr15 Avatar answered Sep 19 '22 11:09

grzchr15