Add option for custom logging format
See original GitHub issueUsing the serializers I can customize what get’s logged. However, I do not have control over the logging format. For example, I would like to log like so:
[1574212772844] INFO (35 on db805887c09f): 11.11.111.111 - GET /url/path - Status Code: 200
Essentially it would mean removing the object with res
& err
here in logger.js
:
log[level]({
res: this,
err: err || this.err || new Error('failed with status code ' + this.statusCode),
responseTime: responseTime
}, 'request errored')
return
}
log[level]({
res: this,
responseTime: responseTime
}, 'request completed')
…allowing the user to decide how to format the log.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:14
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Custom log formats | Fastly Help Guides
Fastly provides two versions of custom log formats for use when you ... Click the Edit configuration button and then select the option...
Read more >How do I add custom field to Python log format string?
You can give a default value to the extra field by extending the logging.Formatter class: class CustomFormatter(logging.Formatter): def format( ...
Read more >Logging Cookbook — Python 3.11.1 documentation
Author, Vinay Sajip ,. This page contains a number of recipes related to logging, which have been found useful in the past. For...
Read more >Console log formatting - .NET - Microsoft Learn
Learn how to use available console log formatting, or implement custom log formatting for your .NET applications.
Read more >Create a custom log file format - SolarWinds Documentation
Add an action to log messages to a file and specify the log file format. If you do not want to use the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d like this option as well.
The suggested
11.11.111.111 - GET /url/path - Status Code: 200
format would be preferred in any configuration instead of the defaultrequest completed
message, however i’d also add an option to remove details ofreq
andres
unless I opt into getting them for specific endpoints.This code looks easy enough to fork though, so I won’t wait around too long for it.
How about using pino-pretty in the following way?