Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / log4js / examples / example.js
1 var log4js = require('../lib/log4js');
2 //log the cheese logger messages to a file, and the console ones as well.
3 log4js.configure({
4     appenders: [
5         {
6             type: "file",
7             filename: "cheese.log",
8             category: [ 'cheese','console' ]
9         },
10         {
11             type: "console"
12         }
13     ],
14     replaceConsole: true
15 });
16
17 //to add an appender programmatically, and without clearing other appenders
18 //loadAppender is only necessary if you haven't already configured an appender of this type
19 log4js.loadAppender('file');
20 log4js.addAppender(log4js.appenders.file('pants.log'), 'pants');
21 //a custom logger outside of the log4js/lib/appenders directory can be accessed like so
22 //log4js.loadAppender('what/you/would/put/in/require');
23 //log4js.addAppender(log4js.appenders['what/you/would/put/in/require'](args));
24 //or through configure as:
25 //log4js.configure({
26 //  appenders: [ { type: 'what/you/would/put/in/require', otherArgs: 'blah' } ]
27 //});
28
29 var logger = log4js.getLogger('cheese');
30 //only errors and above get logged.
31 //you can also set this log level in the config object
32 //via the levels field.
33 logger.setLevel('ERROR');
34
35 //console logging methods have been replaced with log4js ones.
36 //so this will get coloured output on console, and appear in cheese.log
37 console.error("AAArgh! Something went wrong", { some: "otherObject", useful_for: "debug purposes" });
38 console.log("This should appear as info output");
39
40 //these will not appear (logging level beneath error)
41 logger.trace('Entering cheese testing');
42 logger.debug('Got cheese.');
43 logger.info('Cheese is Gouda.');
44 logger.log('Something funny about cheese.');
45 logger.warn('Cheese is quite smelly.');
46 //these end up on the console and in cheese.log
47 logger.error('Cheese %s is too ripe!', "gouda");
48 logger.fatal('Cheese was breeding ground for listeria.');
49
50 //these don't end up in cheese.log, but will appear on the console
51 var anotherLogger = log4js.getLogger('another');
52 anotherLogger.debug("Just checking");
53
54 //one for pants.log
55 //will also go to console, since that's configured for all categories
56 var pantsLog = log4js.getLogger('pants');
57 pantsLog.debug("Something for pants");
58
59
60