8000 Added syntax highlighting to JS code in README.md · LikeABossProgrammer/log4js-node@0167c84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0167c84

Browse files
committed
Added syntax highlighting to JS code in README.md
1 parent 3e1a27e commit 0167c84

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

README.md

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,49 @@ npm install log4js
3636
## usage
3737

3838
Minimalist version:
39-
40-
var log4js = require('log4js');
41-
var logger = log4js.getLogger();
42-
logger.debug("Some debug messages");
43-
39+
```javascript
40+
var log4js = require('log4js');
41+
var logger = log4js.getLogger();
42+
logger.debug("Some debug messages");
43+
```
4444
By default, log4js outputs to stdout with the coloured layout (thanks to [masylum](http://github.com/masylum)), so for the above you would see:
4545

4646
[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
4747

4848
See example.js for a full example, but here's a snippet (also in fromreadme.js):
49-
50-
var log4js = require('log4js');
51-
//console log is loaded by default, so you won't normally need to do this
52-
//log4js.loadAppender('console');
53-
log4js.loadAppender('file');
54-
//log4js.addAppender(log4js.appenders.console());
55-
log4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese');
56-
57-
8000 var logger = log4js.getLogger('cheese');
58-
logger.setLevel('ERROR');
59-
60-
logger.trace('Entering cheese testing');
61-
logger.debug('Got cheese.');
62-
logger.info('Cheese is Gouda.');
63-
logger.warn('Cheese is quite smelly.');
64-
logger.error('Cheese is too ripe!');
65-
logger.fatal('Cheese was breeding ground for listeria.');
66-
49+
```javascript
50+
var log4js = require('log4js');
51+
//console log is loaded by default, so you won't normally need to do this
52+
//log4js.loadAppender('console');
53+
log4js.loadAppender('file');
54+
//log4js.addAppender(log4js.appenders.console());
55+
log4js.addAppender(log4js.appenders.file('logs/cheese.log'), 'cheese');
56+
```javascript
57+
var logger = log4js.getLogger('cheese');
58+
logger.setLevel('ERROR');
59+
60+
logger.trace('Entering cheese testing');
61+
logger.debug('Got cheese.');
62+
logger.info('Cheese is Gouda.');
63+
logger.warn('Cheese is quite smelly.');
64+
logger.error('Cheese is too ripe!');
65+
logger.fatal('Cheese was breeding ground for listeria.');
66+
```
6767
Output:
6868

6969
[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!
7070
[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.
7171

7272
The first 5 lines of the code above could also be written as:
73-
74-
var log4js = require('log4js');
75-
log4js.configure({
76-
appenders: [
77-
{ type: 'console' },
78-
{ type: 'file', filename: 'logs/cheese.log', category: 'cheese' }
79-
]
80-
});
81-
73+
```javascript
74+
var log4js = require('log4js');
75+
log4js.configure({
76+
appenders: [
77+
{ type: 'console' },
78+
{ type: 'file', filename: 'logs/cheese.log', category: 'cheese' }
79+
]
80+
});
81+
```
8282

8383
## configuration
8484

@@ -91,17 +91,20 @@ By default, the configuration file is checked for changes every 60 seconds, and
9191

9292
To turn off configuration file change checking, configure with:
9393

94-
var log4js = require('log4js');
95-
log4js.configure('my_log4js_configuration.json', {});
96-
94+
```javascript
95+
var log4js = require('log4js');
96+
log4js.configure('my_log4js_configuration.json', {});
97+
```
9798
To specify a different period:
9899

99-
log4js.configure(' 880C ;file.json', { reloadSecs: 300 });
100-
100+
```javascript
101+
log4js.configure('file.json', { reloadSecs: 300 });
102+
```
101103
For FileAppender you can also pass the path to the log directory as an option where all your log files would be stored.
102104

103-
log4js.configure('my_log4js_configuration.json', { cwd: '/absolute/path/to/log/dir' });
104-
105+
```javascript
106+
log4js.configure('my_log4js_configuration.json', { cwd: '/absolute/path/to/log/dir' });
107+
```
105108
If you have already defined an absolute path for one of the FileAppenders in the configuration file, you could add a "absolute": true to the particular FileAppender to override the cwd option passed. Here is an example configuration file:
106109

107110
#### my_log4js_configuration.json ####

0 commit comments

Comments
 (0)
0