1.0.17 • Published 5 years ago

expressjs-file-logger v1.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Prerequisites

Installed Node JS version 7.6 and above and Express JS

How to use the logger

As an application middleware. Example:

const app = express(); 
const loggerService = require('expressjs-file-logger');  

app.use(loggerService(loggerConfig));

Logger config is an object with the following default properties. Any of them could be overriden:

const defaultOptions = {  
   "storagePath": "path.join(process.cwd(), '/logs')",   
   "logType": "day",  
   "logNameSeparator": "-",  
   "logMode": "all",  
   "logRequestBody": "true",  
   "logFilesExtension": ".txt"  
};  

loggerConfig.storagePath - Path for logs' storage. If path does not exist it will be created.

loggerConfig.logType - Default value is 'day'. Every day a new file will be created with the following name 'DD-MM-YYYY'.
loggerConfig.logType - 'hour'. If this option is selected, a new folder will be created inside loggerConfig.storagePath for every day with the name 'DD-MM-YYYY'. Filenames inside it will be 'DD-MM-YYYY-HH'.

loggerConfig.logNameSeparator - by default '-'. This is the separator used for file and directory names.
loggerConfig.logMode - by default 'all', logger will log every request. If set to 'errors', it will log only 400 and above status codes.
loggerConfig.logRequestBody - by default true, logger will log every request's body. If set to false, it will log only status code and status message.
loggerConfig.logRequestBody - by default .txt. Files will be saved with '.txt' extension. Could be overriden to '.log' or any other appropriate fromat.

Note - all dates are UTC format. Module uses async/await so Node JS version should support it

1.0.17

5 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago