Giter VIP home page Giter VIP logo

Comments (12)

paulvi avatar paulvi commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

paulvi avatar paulvi commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

paulvi avatar paulvi commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

paulvi avatar paulvi commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

dougwilson avatar dougwilson commented on May 5, 2024

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.

paulvi avatar paulvi commented on May 5, 2024

That is convenient

from morgan.

dougwilson avatar dougwilson commented on May 5, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.