couchdbcouchapp

Custom logging in couch.log from couchapp?


Is it possible to write in the couchdb server log (the one defined by default.ini or local.ini in [log]) from a couchapp? (But from somewhere else than a view)

If that's not possible, maybe there's a workaround which would allow to log successful or unsuccessful authentication attemps in the couchdb server log? I'd like to process this server side and would like to avoid logging all httpd activity and grepping for user logging patterns, which doesn't seem to be easy or pretty...

Cheers,

Jun


Solution

  • A year later I find that it was in fact possible to log from views (or lists or any Javascript Design Doc functions) using the log() function: http://docs.couchdb.org/en/1.6.1/query-server/javascript.html#log

    log(message)

    Log a message to the CouchDB log (at the INFO level).

    Arguments:
    message – Message to be logged

    function(doc){
        log('Procesing doc ' + doc['_id']);
        emit(doc['_id'], null);
    }
    

    After the map function has run, the following line can be found in CouchDB logs (e.g. at /var/log/couchdb/couch.log):

    [Sat, 03 Nov 2012 17:38:02 GMT] [info] [<0.7543.0>] OS Process #Port<0.3289> Log :: Processing doc 8d300b86622d67953d102165dbe99467
    

    Who would have guessed :)