Thursday, March 23, 2017

JSON logging support is added to H2O HTTP/2 server version 2.2.0-beta3

Today I am happy to announce the release of H2O HTTP/2 server, version 2.2.0-beta3.

Among the new features you will be finding in 2.2, in this blogpost I would like to talk about our support for JSON logging.

Traditionally, the log file format of HTTP servers have followed the tradition set by NCSA httpd more than twenty years ago. But the more we try to deal in various ways with the logs, the more it makes sense to use a standardized and extensible format so that we can apply existing tools to the logs being collected. Hence JSON.

Our support for JSON is a smooth evolution from the NCSA- (and Apache-) style logging. Configuration for a JSON logging will look like below.
access-log:
  path: /path/to/access-log.json
  format: '{"remote": "%h:%{remote}p", "at": "%{%Y%m%d%H%M%S}t.%{msec_frac}t", "method": "%m",  "path": "%U%q", "status": %s, "body-size": %b, "referer": "%{referer}i"}'
  escape: json
The template specified by the format attribute uses the exact same specifiers as we use in NCSA-style logging. The only differences are that the non-substituted part of the template is JSON, and that another attributed named escape is set to json. The attribute instructs the logger to emit things in a JSON-compatible manner.

Specifically, the behavior of the logger is changed to be:
  • strings are escaped in JSON style (i.e. \u00nn) instead of \xnn
  • nulls are emitted as null instead of -

The format may seem a bit verbose, but gives you the power to name the elements of a JSON object as you like, and to choose whatever format you want to use for compound values (e.g. the date, as shown in the example above).

When accessed by a client, a log line like below will be emitted for the above configuration.
{"remote": "192.0.2.1:54389", "at": "20170322161623.023495", "method": "GET", "path": "/index.html", "status": 200, "body-size": 239, "referer": null}
One thing you may notice is that the value of the referer element is emitted as null without the surrounding double quotes that existed in the specified format. When escaping in JSON style, h2o removes the surrounding quotes if the sole value of the string literal is a single format specifier (i.e. %...) and if the format specifier evaluates to null. In other words, "%foo" evaluates to either a string literal or null, while %foo evaluates to a number or null.

If a string literal contains something more than just one format specifier, then the values are concatenated as strings to form a string literal. So "abc%foo" will evalutate to "abcnull".

The other thing that is worth noting is that the substituted values will always be escaped as ISO-8859-1. It is the responsibility of the user to convert the string literals found in the log to the correct character encoding. Such conversion cannot be done at HTTP server level since it requires the knowledge of the application being run. I would like to thank @nalsh for suggesting the approach.

29 comments:



  1. The share your really gives us excitement. Thanks for your sharing. If you feel tired at work or study try to participate in our games to bring the most exciting feeling. Thank you!
    hotmail login | red ball | 192.168.1.1

    ReplyDelete
  2. Thank you for the news and tutorial. It's very helpful.
    lenny face generator

    ReplyDelete
  3. I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog.
    * Happy room play

    ReplyDelete
  4. I like your topic of selection for blog but want to suggest you for sharing some more information regarding your subject so that we can understand your thought more clearly
    starfall games | barney | abcya

    ReplyDelete
  5. Thank you so much for your suggestion and discuss these important points for blog commenting.
    The points you are listed above, really appreciable and will really help in blog commenting or commenting on other posts or topic.
    http://lootindiadeals.com
    http://Whatsappstatus33.com
    https://healthylifeandshape.com
    https://latestwhatsappstatus.blogspot.com

    ReplyDelete
  6. Your article is very useful and has real knowledge. It's very helpful information. I will be waiting for your next post. Keep It up.
    Fathers Day quotes
    Happy Fathers Day Images Quotes
    Happy Fathers Day Funny Quotes
    Fathers Day WhatsApp Status

    ReplyDelete
  7. His subject is good, long while I find this topic and I think it is here, many thanks guys .
    RRB Allahabad Result 2017
    How to Check RRB Ajmer NTPC Result 2017

    ReplyDelete
  8. The choice of topic along with these suggestions are really interesting and hopefully it has contributed a lot to that Find the secret of scoring high with experts online in buy dissertation online uk

    ReplyDelete
  9. The topic is so nice and help for my work.
    - twitter search

    ReplyDelete
  10. Very helpful advice in this particular post! It’s the little changes that make the largest changes. Thanks for sharing!

    -- instagram video downloader --

    ReplyDelete
  11. This blog is great i love reading your posts. Keep up the great work! You know, a lot of people are hunting around for this info, you could help them greatly.
    coursework Writing Service

    ReplyDelete
  12. I will make sure to bookmark your blog and may come
    back later in life. I want to encourage continue your great posts,
    have a nice evening!
    Sony Liv Live
    Totalsportek Live Stream
    Supercopa Barcelona vs Real Madrid Live Stream

    ReplyDelete
  13. Yes, the article I was looking for. Your article gives me another approach on the subject. I hope to read more articles from you.
    html color

    ReplyDelete
  14. Thanks for your post! Through your pen I found the problem up interesting! I believe there are many other people who are interested in them just like me! Thanks your shared!... I hope you will continue to have similar posts to share with everyone!
    io games

    ReplyDelete
  15. GaleriQQ Telah menjadi salah satu agen domino99 atau agen bandarq terfavorite untuk para pemain poker dan domino di seluruh indonesia karena di GaleriQQ lah lahir para master poker dan domino handal juga Jutawan - Jutawan Baru Setiap Harinya, Super sekali...!!!

    Kami juga menyediakan bonus - bonus yang sangat menarik untuk para member - member tercinta kami di situs kami GaleriQQ.com loh..!!!
    Berikut Promo Yang Di Berikan GaleriQQ Ini :
    - Bonus Rollinggan 0.5% setiap Minggunya
    - Bonus Refferal 20% Seumur Hidup
    - Dan Masih Banyak Bonus Menarik laen nya yang menanti anda semua
    - Kemudahan Menang Besar Yang Sangat Terbuka Untuk anda semua tanpa syarat apapun

    GaleriQQ meyediakan 7 games yang dapat anda bermain dengan 1 user ID saja yaitu :
    * Poker Online
    * Domino 99
    * Bandarq
    * AduQ
    * Bandar Poker
    * Capsa Susun
    * Sakong

    GaleriQQ Juga di support dan di dukung oleh bank lokal ternama diantaranya yaitu : BCA - BNI - BRI - MANDIRI - DANAMON - CIMB NIAGA
    Dan anda semua juga tidak perlu khawatir saat mau melakukan login kedalam GaleriQQ ini dikarenakan situs yang satu ini memiliki kualitas teknologi yang super canggih dan menyediakan link alternatif untuk anda semua untuk mempermudah anda untuk melakukan login ke website GaleriQQ tentunya.

    ReplyDelete
  16. Awesome Post! Check out Happy Diwali 2017 Whatsapp Status
    Also download latest movie Stranger Things
    Also Read trending Story Tragically Selfie Attempt
    Also Check out Latest vacancy of Government Job Indian Army Recruitment 2017

    ReplyDelete
  17. Samsung Galaxy S9 is unbreakable. To know more Samsung Galaxy S9

    ReplyDelete
  18. The article you have shared here very good. This is really interesting information for me. Thanks for sharing!
    hotmail login |hotmail sign in |free hotmail login

    ReplyDelete
  19. شركة نقل عفش
    اهم شركات مكافحة حشرات بالخبر كذلك معرض اهم شركة مكافحة حشرات بالدمام والخبر والجبيل والخبر والاحساء والقطيف كذلك شركة رش حشرات بالدمام ومكافحة الحشرات بالخبر
    شركة مكافحة حشرات بالدمام
    شركة تنظيف خزانات بجدة الجوهرة من افضل شركات تنظيف الخزانات بجدة حيث ان تنظيف خزانات بجدة يحتاج الى مهارة فى كيفية غسيل وتنظيف الخزانات الكبيرة والصغيرة بجدة على ايدى متخصصين فى تنظيف الخزانات بجدة
    شركة تنظيف خزانات بجدة
    شركة كشف تسربات المياه بالدمام
    شركة نقل عفش واثاث

    ReplyDelete
  20. http://emcmee.jimdo.com/%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%A7%D8%AB%D8%A7%D8%AB-%D8%A8%D8%A7%D9%84%D8%B1%D9%8A%D8%A7%D8%B6/ شركة نقل عفش بالرياض
    http://emcmee.jimdo.com/%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%B9%D9%81%D8%B4-%D8%A8%D8%A7%D9%84%D8%B7%D8%A7%D8%A6%D9%81/ شركة نقل عفش بالطائف
    http://emcmee.jimdo.com/%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%B9%D9%81%D8%B4-%D8%A8%D8%A7%D9%84%D8%AF%D9%85%D8%A7%D9%85/ شركة نقل عفش بالدمام
    http://emcmee.jimdo.com/%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%A7%D8%AB%D8%A7%D8%AB-%D8%A8%D8%AC%D8%AF%D8%A9/ شركة نقل عفش بجدة
    http://emcmee.jimdo.com/%D8%B4%D8%B1%D9%83%D8%A9-%D9%86%D9%82%D9%84-%D8%B9%D9%81%D8%B4-%D8%A8%D8%A7%D9%84%D9%85%D8%AF%D9%8A%D9%86%D8%A9-%D8%A7%D9%84%D9%85%D9%86%D9%88%D8%B1%D8%A9/ شركة نقل عفش بالمدينة المنورة

    ReplyDelete

  21. درمان درد مقعدی
    جراحی شقاق
    <a href="http://www.drdarman.ir/fistol-maghad>جراحی فیستول مقعد</a>

    ReplyDelete