I can specify custom log format for access log in nginx, but it won't work for error log. I wish I always saw time when error occur. Is it possible?
相关问题
- I want to trace logs using a Macro multi parameter
- Error message 'No handlers could be found for
- convert logback.xml to log4j.properties
- Django management command doesn't show logging
- apache modules ap_log_perror is at a different lev
You can't specify your own format, but in nginx build-in several level's of error_log-ing.
Syntax:
error_log file [ debug | info | notice | warn | error | crit ]
Default:
${prefix}/logs/error.log
Specifies the file where server (and fastcgi) errors are logged.
Default values for the error level:
In my error_log, time always presented int begin of each error string in log.
A dirty trick I used when I wanted to change the format of the nginx error log (in this case when sending my own logs with openresty's
ngx.log
method from Lua) was to prefix my own log message with enough\b
(backspace) characters to delete all the information I wasn't interested in viewing when running atail -f error.log
.There is a hack for that.
We know that we can customize the access log format but not error log format. So the hack is, for customized error log, we generate access log only when error occurs.
This can be done using error_page directive.