Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support logstash JSON format to File transport #445

Merged
merged 1 commit into from
Sep 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ The File transport should really be the 'Stream' transport since it will accept
* __maxFiles:__ Limit the number of files created when the size of the logfile is exceeded.
* __stream:__ The WriteableStream to write output to.
* __json:__ If true, messages will be logged as JSON (default true).
* __logstash:__ If true, messages will be logged using the logstash JSON format.

*Metadata:* Logged via util.inspect(meta);

Expand Down
4 changes: 3 additions & 1 deletion lib/winston/transports/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ var File = exports.File = function (options) {
this.prettyPrint = options.prettyPrint || false;
this.label = options.label || null;
this.timestamp = options.timestamp != null ? options.timestamp : true;
this.logstash = options.logstash || false;

if (this.json) {
this.stringify = options.stringify;
Expand Down Expand Up @@ -126,7 +127,8 @@ File.prototype.log = function (level, msg, meta, callback) {
prettyPrint: this.prettyPrint,
timestamp: this.timestamp,
stringify: this.stringify,
label: this.label
label: this.label,
logstash: this.logstash
}) + '\n';

this._size += output.length;
Expand Down