Configures comb.Logger with the properties or properties contained within a file
Examplevar propertyConfigurator = new comb.logging.PropertyConfigurator(); propertyConfigurator.configure("/location/of/combLogger.json"); //or var config = { "my.logger" : { level : "INFO", appenders : [ { //default file appender type : "FileAppender", file : "/var/log/myApp.log", }, { //default JSON appender type : "JSONAppender", file : "/var/log/myApp.JSON", }, { type : "FileAppender", //override default patter pattern : "{[EEEE, MMMM dd, yyyy h:m a]timeStamp} {[5]level}" + " {[- 5]levelName} {[-20]name} : {message}", //location of my log file file : "/var/log/myApp-errors.log", //override name so it will get added to the log name : "errorFileAppender", //overwrite each time overwrite : true, //explicity set the appender to only accept errors level : "ERROR" }, { type : "JSONAppender", file : "/var/log/myApp-error.json", //explicity set the appender to only accept errors level : "ERROR" } ] } //repeat for more loggers propertyConfigurator.configure(config); }Extends
Call to configure logging
Example//Example configuration { "my.logger" : { level : "INFO", appenders : [ { //default file appender type : "FileAppender", file : "/var/log/myApp.log", }, { //default JSON appender type : "JSONAppender", file : "/var/log/myApp.JSON", }, { type : "FileAppender", //override default patter pattern : "{[EEEE, MMMM dd, yyyy h:m a]timeStamp} {[5]level}" + " {[- 5]levelName} {[-20]name} : {message}", //location of my log file file : "/var/log/myApp-errors.log", //override name so it will get added to the log name : "errorFileAppender", //overwrite each time overwrite : true, //explicity set the appender to only accept errors level : "ERROR" }, { type : "JSONAppender", file : "/var/log/myApp-error.json", //explicity set the appender to only accept errors level : "ERROR" } ] }Arguments
Object containing configuration or string containing a file name with the configuration.
function (properties){ var rootLogger = Logger.getRootLogger(); rootLogger.removeAllAppenders(); if (base.isHash(properties)) { parseProperties(base.deepMerge({}, properties)); } else { fs.readFile(properties, function (err, res) { if (err) { throw err; } else { try { parseProperties(JSON.parse(res)); } catch (e) { throw e; } } }); } }
MIT https://github.com/C2FO/comb/raw/master/LICENSE
git clone git://github.com/C2FO/comb.git