mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Merge branch 'master' into version-3.x
This commit is contained in:
commit
5618fdb4f8
@ -24,7 +24,6 @@ The following appenders are included with log4js. Some require extra dependencie
|
||||
* [dateFile](dateFile.md)
|
||||
* [file](file.md)
|
||||
* [fileSync](fileSync.md)
|
||||
* [logFaces-HTTP](logFaces-HTTP.md)
|
||||
* [logFaces-UDP](logFaces-UDP.md)
|
||||
* [logLevelFilter](logLevelFilter.md)
|
||||
* [multiFile](multiFile.md)
|
||||
@ -41,6 +40,7 @@ The following appenders are supported by log4js, but are no longer distributed w
|
||||
|
||||
* [gelf](https://github.com/log4js-node/gelf)
|
||||
* [hipchat](https://github.com/log4js-node/hipchat)
|
||||
* [logFaces-HTTP](https://github.com/log4js-node/logFaces-HTTP)
|
||||
* [loggly](https://github.com/log4js-node/loggly)
|
||||
* [logstashHTTP](https://github.com/log4js-node/logstashHTTP)
|
||||
* [logstashUDP](https://github.com/log4js-node/logstashUDP)
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
# logFaces Appender (HTTP)
|
||||
|
||||
The logFaces appenders send JSON formatted log events to [logFaces](http://www.moonlit-software.com) receivers. This appender uses HTTP to send the events (there is another logFaces appender that uses [UDP](logFaces-UDP.md)). You will need to include [axios](https://www.npmjs.com/package/axios) in your dependencies to use this appender.
|
||||
|
||||
## Configuration
|
||||
|
||||
* `type` - `logFaces-HTTP`
|
||||
* `url` - `string` - logFaces receiver servlet URL
|
||||
* `application` - `string` (optional, defaults to empty string) - used to identify your application's logs
|
||||
* `timeout` - `integer` (optional, defaults to 5000ms) - the timeout for the HTTP request.
|
||||
|
||||
This appender will also pick up Logger context values from the events, and add them as `p_` values in the logFaces event. See the example below for more details.
|
||||
|
||||
# Example (default config)
|
||||
|
||||
```javascript
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
logfaces: { type: 'logFaces-HTTP', url: 'http://lfs-server/logs' }
|
||||
},
|
||||
categories: {
|
||||
default: { appenders: [ 'logfaces' ], level: 'info' }
|
||||
}
|
||||
});
|
||||
|
||||
const logger = log4js.getLogger();
|
||||
logger.addContext('requestId', '123');
|
||||
logger.info('some interesting log message');
|
||||
logger.error('something has gone wrong');
|
||||
```
|
||||
This example will result in two log events being sent to `lfs-server`. Both events will have a `p_requestId` property with a value of `123`.
|
||||
@ -1,4 +1,7 @@
|
||||
/**
|
||||
* This appender is deprecated. All bugfixes and improvements should be made in
|
||||
* https://github.com/log4js-node/logFaces-HTTP
|
||||
*
|
||||
* logFaces appender sends JSON formatted log events to logFaces receivers.
|
||||
* There are two types of receivers supported - raw UDP sockets (for server side apps),
|
||||
* and HTTP (for client side apps). Depending on the usage, this appender
|
||||
@ -33,7 +36,7 @@ function logFacesAppender(config) {
|
||||
withCredentials: true
|
||||
});
|
||||
|
||||
return function log(event) {
|
||||
const appender = function log(event) {
|
||||
// convert to logFaces compact json format
|
||||
const lfsEvent = {
|
||||
a: config.application || '', // application name
|
||||
@ -58,6 +61,9 @@ function logFacesAppender(config) {
|
||||
console.error(`log4js.logFaces-HTTP Appender error: ${error.message}`);
|
||||
});
|
||||
};
|
||||
|
||||
appender.deprecated = '@log4js-node/logfaces-http';
|
||||
return appender;
|
||||
}
|
||||
|
||||
function configure(config) {
|
||||
|
||||
19
types/log4js.d.ts
vendored
19
types/log4js.d.ts
vendored
@ -6,7 +6,7 @@ export interface Log4js {
|
||||
configure(config: Configuration): Log4js;
|
||||
addLayout(name: string, config: (a: any) => (logEvent: LoggingEvent) => string): void;
|
||||
connectLogger(logger: Logger, options: { format?: string; level?: string; nolog?: any; }): any; // express.Handler;
|
||||
levels(): Levels;
|
||||
levels: Levels;
|
||||
shutdown(cb?: (error: Error) => void): void | null;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ export function addLayout(name: string, config: (a: any) => (logEvent: LoggingEv
|
||||
|
||||
export function connectLogger(logger: Logger, options: { format?: string; level?: string; nolog?: any; }): any; // express.Handler;
|
||||
|
||||
export function levels(): Levels;
|
||||
export const levels: Levels;
|
||||
|
||||
export function shutdown(cb?: (error: Error) => void): void | null;
|
||||
|
||||
@ -257,10 +257,17 @@ export type Appender = CategoryFilterAppender
|
||||
| CustomAppender;
|
||||
|
||||
export interface Levels {
|
||||
[index: string]: {
|
||||
value: number;
|
||||
colour: string;
|
||||
};
|
||||
ALL: Level;
|
||||
MARK: Level;
|
||||
TRACE: Level;
|
||||
DEBUG: Level;
|
||||
INFO: Level;
|
||||
WARN: Level;
|
||||
ERROR: Level;
|
||||
FATAL: Level;
|
||||
OFF: Level;
|
||||
levels: Level[];
|
||||
getLevel(level: string): Level;
|
||||
}
|
||||
|
||||
export interface Configuration {
|
||||
|
||||
@ -117,3 +117,6 @@ log4js.configure('./filename').getLogger();
|
||||
const logger7 = log4js.getLogger();
|
||||
logger7.level = 'debug';
|
||||
logger7.debug("Some debug messages");
|
||||
|
||||
const levels: log4js.Levels = log4js.levels;
|
||||
const level: log4js.Level = levels.getLevel('info');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user