[
https://issues.apache.org/jira/browse/HTRACE-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14288604#comment-14288604
]
Colin Patrick McCabe commented on HTRACE-89:
--------------------------------------------
So, a little background here:
I wanted a system that could support multiple log levels (TRACE, DEBUG, INFO,
WARN, ERROR), similar to how we have in Hadoop. This kind of ruled out the go
standard library's package, which just has fatal logs and non-fatal logs, but
no log levels. (The standard library's package DOES have a way to write to
files, though... just not log levels).
I took a look at log4go at https://code.google.com/p/log4go. This version
seems to be the original and is by someone whose username is "etherealflaim"
Unfortunately, it hasn't been updated in a while... the last commit is from
early 2012. It's a good package in many ways, but I didn't like the fact that
logging is async in this package. When a crash happens, you really want to
know what triggered it, not be guessing because the unflushed log buffers
evaporated. There are also a bunch of forks of this package that are being
more actively maintained, but they all appear to be also async as far as I can
tell.
(Google Code's web interface appears to have become self-aware, and is not
letting me find out more information about "etherealflaim." I am not good with
captchas...)
Confusingly, Doug Muth also started a log4go package which is unrelated to the
"etherealflaim" one. It appears to have been started later that the other one.
It's GPLv3, which excludes it from consideration here in view of Apache's
policies.
There is also "logrus" by Simon Eskildsen, which seems to be more geared to
structured logging. In logrus your logs are more like JSON objects with keys
and values. I think structured logging is just too much work... when I think
of logs that are structured, I think of the HBase WAL or the HDFS WAL, not log
designed to be read by humans. Also, unstructured logging will be more
familiar to developers coming from Hadoop.
So I wrote a little glue code to implement levels and write to a file in
{{org/apache/htrace/common/log.go}}. The idea here is that you have log levels
and log "faculties". A "faculty" would be something like "datastore" or
"rest". So if you want to see trace logs from the datastore, you set this
config key:
{code}
datastore.log.level=TRACE
{code}
There is a "root" log level that gets used if there is no configured log level
for a particular faculty. So if the user didn't specify {{rest.log.level}}, we
use the value of the {{log.level}} configuration key (which defaults to INFO).
{{log.path}} works similarly. If path is an empty string, we use stdout.
I think we should get this in for now, and we can always make it fancier later.
It's an important step in making htraced production-ready.
> htraced: add log levels, writing to log files
> ---------------------------------------------
>
> Key: HTRACE-89
> URL: https://issues.apache.org/jira/browse/HTRACE-89
> Project: HTrace
> Issue Type: New Feature
> Affects Versions: 3.2.0
> Reporter: Colin Patrick McCabe
> Assignee: Colin Patrick McCabe
> Attachments: HTRACE-89.001.patch
>
>
> htraced should have log levels and the ability to write to log files.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)