Logging

The 10gen logging module writes log events to the database. This provides a global log view of the entire application, regardless of the number of servers involved. Logging is very fast. See Fixed Sized Collection.

Logging API

  • basic logging
    • log( "foo" );
  • sub loggers
    • log.foo( "hi" );
    • log.foo.bar( "hi" );
  • levels
    • log.foo.debug( "i'm just a debug message" )
    • log.foo.info( "i'm an info message" )
    • log.foo.error( "i'm an error" )
    • log.foo.fatal( "uh oh - something is wrong" )

Viewing

  • http://yoursite/admin/logMemory
  • http://yoursite/admin/logScroll
Because log events are in the database, you can write your own log view utility or "grep" the log with find() statements containing a regular expression as the query.

Creating a Custom Appender

function appender( loggerName , date , level , msg , throwable , thread ){
   email( "me" , "something broke" , loggerName + " " + msg );
}

log.appenders.push( javaCreate( "ed.log.JSAppender" , append ) )