Comments (12)
There should be option to use toISOString()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
var today = new Date("05 October 2011 14:48 UTC");
alert(today.toISOString()); // Returns 2011-10-05T14:48:00.000Z
from morgan.
The default value is to match Apache-style access logs, which everyone matches since there are existing log analytics tools to process these logs.
The way to change your date
token style (or any token) is the following:
var morgan = require('morgan')
morgan.token('date', function(){
return new Date().toISOString()
})
from morgan.
morgan
is really flexible thanks to JavaScript.
"Tue, 21 Oct 2014 10:49:02 GMT" is close what is Java default output, and what is in students' software
On the http://httpd.apache.org/docs/2.2/logs.html page format is
10/Oct/2000:13:55:36 -0700
But I am concern mostly about 2 points:
- less significant digits are on the most right side, like in numbers.
- should show seconds fraction to enable performance analysis (with current default this information is lost)
from morgan.
Ah. Looks like I should change the default token to be in the format "10/Oct/2000:13:55:36 -0700" instead. Thanks!
from morgan.
should show seconds fraction to enable performance analysis (with current default this information is lost)
the access date/time has nothing to do with performance. you want to use the :response-time
token for that, which is sub-second resolution already.
from morgan.
Nice hint about :reponse-time
I took a look at Apache Tomcat logs
[2012-11-15 11:46:25] [info] Procrun (2.0.3.0) started
[2012-11-15 11:46:25] [info] Service Tomcat6 name Apache Tomcat
[2012-11-15 11:46:25] [info] Service Tomcat6 installed
[2012-11-15 11:46:25] [info] Procrun finished.
2012-11-15 11:46:25 style is the most readable and short for log
I would still add second fraction
Just like default in the latest Jetty
D:\Progs\jetty-distribution-9.2.3.v20140905>java -jar start.jar
2014-10-22 13:56:48.693:INFO::main: Logging initialized @620ms
2014-10-22 13:56:48.928:INFO:oejs.Server:main: jetty-9.2.3.v20140905
2014-10-22 13:56:48.950:INFO:oejdp.ScanningAppProvider:main: Deployment monito
2014-10-22 13:56:50.489:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebApp
2014-10-22 13:56:50.602:INFO:oejs.ServerConnector:main: Started ServerConnecto
2014-10-22 13:56:50.605:INFO:oejs.Server:main: Started @2548ms
2014-10-22 13:58:44.652:INFO:oejsh.ContextHandler:Thread-0: Stopped o.e.j.w.We
from morgan.
As far as the default log timestamp goes, none of those logs are access logs, which have a pretty standard format and are actually analyzed using analytics programs, unlike the ones you displayed. This means that the date time needs to be in a format the log analyzers actually understand.The current format moran is using they can understand, but it isn't the CLF (https://en.wikipedia.org/wiki/Common_Log_Format) date time, so in the next major of morgan, I'll change it to be the CLF date time format.
from morgan.
I can't tell about log analysis software, as while trying a few I still mostly do search or grep-like operation.
I'll change it to be the CLF date time format.
That would be better. Also README should show how to customize #38
from morgan.
I can't tell about log analysis software
i.m.o the biggest one is AWStats (http://www.awstats.org/)
Also README should show how to customize
Yes, I saw your PR :) I just needs to adjust the wording and such before I merge it in, though it's really late here in the US, so it won't be until tomorrow (~8 hours).
from morgan.
So you can, as of version 1.5.0, use the token :date[iso]
to get the format you want without needing to define your own token.
from morgan.
That is convenient
from morgan.
P.S. I don't know why I didn't think of doing that earlier (having an argument to date
), otherwise it would have already been there :D
from morgan.
Related Issues (20)
- Error: EBADF: bad file descriptor, write HOT 7
- Is there a way to get the start time instead of the finish time?
- Custom tokens returning function string HOT 1
- Is this compatible with angular 11? HOT 1
- Usage in ES6 promise based import does not work HOT 1
- skip function not working with 'immediate:true' configuration HOT 3
- Colored status token HOT 1
- Dexter Morgan HOT 2
- Use morgan as custom console logger HOT 3
- morgan block my auth login redirection when I use createWriteStream for stream option HOT 9
- Adding a token named token causes all subsequent tokens to break. HOT 3
- req.route.path value is undefined HOT 3
- :res[content-length] only shows size less than 1 KB HOT 2
- Support for promise HOT 2
- Getting vulnerable issue [email protected] HOT 1
- Expose `stream.write` as option HOT 2
- webscoket request should be logged HOT 2
- SPDY > Express.JS > Next.JS don't show path details.
- `User: ':remote-user'` does not show logged-in user but `-`
- Issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from morgan.