Thanks Tim.

Great suggestions and ideas. This is somewhere along the lines I am coming from.

" The best way to win that entire game is not to play." -  I really wish I had 
that choice. But given that we're running a pretty big team with significant 
code being churned out, only choice I have is to ensure the logs are structured.

Regards
Arnab

-----Original Message-----
From: Tim Boudreau [mailto:niftin...@gmail.com] 
Sent: Friday, March 15, 2019 11:38 AM
To: dev@netbeans.incubator.apache.org
Subject: Re: Question | Logger | NetBeans plugin

If you're really looking for machine-readable log messages, Bunyan is an 
elegant solution for NodeJS [1].  I wrote a Java port [2][3][4] - no connection 
the the JDK logger, but probably one could write a JDK logger formatter that 
would format messages (though it would be ugly and purely by convention).

It's a particularly simple and elegant approach:  A log message is a single 
line of JSON with a few required fields and the rest freeform.  It also makes 
it absurdly easy to do things such as create a tiny HTTP server that lets you 
stream live log messages and parse and present them prettily in a browser, or 
chew on them in other ways.  NodeJS bunyan also comes with some handy 
command-line tools for filtering live logs (also useful with curl).

The bottom line on logging is that, once upon the time, Apache had horrible log 
files. And everybody looked at that and said "Hey, they have log files!  
Whatever they did must be right".  And an industry evolved around parsing 
horrific crap to try to turn it into something useful.  And everybody's 
expectations were set that logs were going to be horrible, and more horrible 
things had to be invented to parse them.  The JDK's logger is in that tradition 
- that's what people thought they wanted.  The best way to win that entire game 
is not to play.

Anyway, yes, you could do something with the JDK's logger, or write a wrapper 
around it (better), to structure log messages (say, throw key value pairs into 
a map and write that as JSON) - what I did for bunyan-java was use 
AutoCloseable to let you add key value pairs to a log record on the fly and 
flush it on close - it works pretty nicely, since you can capture a bunch of 
information about what is happening, failures, etc. in a single log message as 
the code does its work:

        try (Log<?> log = downloadLog.info("download")) {
            log.add("cnb", item.codeNameBase())
                    .add("id", id.get())
                    .add("version", item.getVersion())
                    .add("hash", item.hash())
                    .add(evt);
        }


[1] 
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_trentm_node-2Dbunyan&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=jK-bGbSaQC4T4jM5NL_USJ-dSFwzgBHeZKcThpa2-t8&e=
[2] 
https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_timboudreau_bunyan-2Djava&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=QOGTkLgX5btkx6tF5-r0XzrTcYdeioQBWDcrXZ9ssX8&e=
[3]
https://urldefense.proofpoint.com/v2/url?u=https-3A__timboudreau.com_builds_job_mastfrog-2Dparent_lastSuccessfulBuild_artifact_bunyan-2Djava_bunyan-2Djava_target_apidocs_index.html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=I0_w-dEeAPm_-4W9SHmofLm8MKZPCeN7leda5SKrwf4&e=
[4] 
https://urldefense.proofpoint.com/v2/url?u=https-3A__timboudreau.com_blog_bunyan_read&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=Se62QbyIZJfvKnpzC6BocCeJ7cdahda2Q1cAcJjF8TA&e=

On Fri, Mar 15, 2019 at 12:24 AM Arnab Chanda <arnab.cha...@oracle.com>
wrote:

> Hi JT/Geertjan,
>
> This link talks about enabling the logging for NetBeans. I'm looking 
> for a netbeans plugin (if it exists) that would actually decorate the 
> code with structured logger messages on the source code I'm working on.
>
> For example, there is a plugin in netbeans that allows us to scan the 
> code written for possible sonar violations. I'm looking for something 
> similar, except that this one would write the logger messages for us too.
>
> Best.
> Arnab
>
> -----Original Message-----
> From: Jaroslav Tulach [mailto:jaroslav.tul...@gmail.com]
> Sent: Thursday, March 14, 2019 10:35 PM
> To: Apache NetBeans
> Subject: Re: Question | Logger | NetBeans plugin
>
> > Does this help:
>
> >
> > https://urldefense.proofpoint.com/v2/url?u=http-3A__bits.netbeans.or
> > g_ 
> > dev_javadoc_org-2Dopenide-2Dutil_org_openide_util_doc-2Dfiles_logging.
> > html&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkK
> > GF 
> > vzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nszPclj17EwS1Ks_Nz9KrSfHWXdOQq
> > Ca VAR4F_M87G4&s=cDusfSiabzT96MpOjH--WrE3X4IAVUkv2L1CMJ3vjoY&e=
> >
> >
> Right Geertjan, that is the best thing to do. "Using Structured 
> Logging for Communication" is the best logging pattern possible with 
> java.util.logging infrastructure, in my opinion.
>
> -jt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
> For additional commands, e-mail: 
> dev-h...@netbeans.incubator.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__cwiki.apache.org_
> confluence_display_NETBEANS_Mailing-2Blists&d=DwIBaQ&c=RoP1YumCXCgaWHv
> lZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IR
> A5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=1hieZhpJIzHVPQ3Pp
> dgcBviFWaW3Ez3qrRS2fdN4Lvk&e=
>
>
>
>

--
https://urldefense.proofpoint.com/v2/url?u=http-3A__timboudreau.com&d=DwIBaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=D1IHkKGFvzxf_5_uVPbRqKrc_sYohvaaqKm9-IRA5w4&m=nDsBOXztYZapv2na7rEgL33-S5njlLMAd6ipZ6Oee48&s=TtG0SwOkgwZb8WH6on7vBBt6z9TWm7cUtOXAvyXsMoY&e=

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@netbeans.incubator.apache.org
For additional commands, e-mail: dev-h...@netbeans.incubator.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Reply via email to