apache - 将Apache日志的精度提高到毫秒

标签 apache timestamp syslog rsyslog

我已经修改了rsyslogd的配置以禁用RSYSLOG_TraditionalFileFormat
但是,apache日志/var/log/apache/error.log仍然仅显示第二个精度。

还有其他需要配置的内容吗?

最佳答案

http://httpd.apache.org/docs/current/mod/mod_log_config.html
您会看到不同的时间格式,包括毫秒
只是从

%t 
to 
%{%d/%b/%Y:%T}t-%{msec_frac}t for miliseconds
or
%{%d/%b/%Y:%T}t-%{usec_frac}t for microsecs
例子:
16/三/2013:22:44:34-634
16/三/2013:22:44:34-634200
文档化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)格式化
http://man7.org/linux/man-pages/man3/strftime.3.html

关于apache - 将Apache日志的精度提高到毫秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15405719/

相关文章:

比较和解释两个时间计数器

MySQL 时间戳仅在创建时

c - 在 C 中记录错误

logging - 如何将系统日志发送到graylog

apache - 关于下载 Apache Tomcat 的问题

ruby-on-rails - 将 example.com 重定向到在本地主机 :3000 leaving apache sites intact? 上运行的 Rails 服务器

python - Django - 使用自定义的 login_required 装饰器保护 Apache 提供的媒体文件

java - 如果字符串中缺少一部分,如何设置时间戳?

java - 如何让 log4j syslog appender 在一行中写入堆栈跟踪?

javascript - 从外部访问内部网络摄像头 (www)?