You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "chrisdutz (via GitHub)" <gi...@apache.org> on 2023/06/02 06:32:16 UTC

[D] [Java] How should we handle "loggers"? (plc4x)

GitHub user chrisdutz created a discussion: [Java] How should we handle "loggers"?

When going through our code, I've noticed that we have different ways of defining our loggers. I think it would be cool, if we could decide on one.

In general there are two ways to declare the loggers:
1. as a local variable
2. as a static variable

However usually static variables are all uppercase, but I'm also seeing some static loggers named as local variables.

GitHub link: https://github.com/apache/plc4x/discussions/973

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by Cesar Garcia <ce...@ceos.com.ve>.
Hello,

Totally agree on equalizing the use of logs (log, LOG, logger, LOGGER), and
so on...

If there is a best practice that does not imply adding more libraries to
the existing ones, we should evaluate it.

Kind regards,

El sáb, 3 jun 2023 a las 17:18, Łukasz Dywicki (<lu...@code-house.org>)
escribió:

> The static logger declaration is still a thing made by (older/elder? ;))
> java developers, mainly because log4j 1.x/commons-logging/jul loggers
> were advised to be made like that. With switch to slf4j static is no
> longer mandatory/strongly recommended.
> Most of code I make myself rely on logger field, but I've seen people
> who do it with `@Slf4j` annotation coming from Lombok.
>
> Anyhow, is there a intention (not yet a plan) to unify this part of our
> code?
>
> Best,
> Łukasz
>
> On 2.06.2023 08:35, chrisdutz (via GitHub) wrote:
> >
> > GitHub user chrisdutz added a comment to the discussion: [Java] How
> should we handle "loggers"?
> >
> > And here ... even the Slf4j folks no longer recommend any general way of
> doing things: https://www.slf4j.org/faq.html#declared_static
> > I guess in the past, there was a performance reason to to things, but
> this no longer seems to apply today.
> >
> > GitHub link:
> https://github.com/apache/plc4x/discussions/973#discussioncomment-6068178
> >
> > ----
> > This is an automatically sent email for dev@plc4x.apache.org.
> > To unsubscribe, please send an email to:
> dev-unsubscribe@plc4x.apache.org
> >
>


-- 
*CEOS Automatización, C.A.*
*GALPON SERVICIO INDUSTRIALES Y NAVALES FA, C.A.,*
*PISO 1, OFICINA 2, AV. RAUL LEONI, SECTOR GUAMACHITO,*

*FRENTE A LA ASOCIACION DE GANADEROS,BARCELONA,EDO. ANZOATEGUI*
*Ing. César García*

*Cel: +58 414-760.98.95*

*Hotline Técnica SIEMENS: 0800 1005080*

*Email: support.aan.automation@siemens.com
<su...@siemens.com>*

Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by Łukasz Dywicki <lu...@code-house.org>.
The static logger declaration is still a thing made by (older/elder? ;)) 
java developers, mainly because log4j 1.x/commons-logging/jul loggers 
were advised to be made like that. With switch to slf4j static is no 
longer mandatory/strongly recommended.
Most of code I make myself rely on logger field, but I've seen people 
who do it with `@Slf4j` annotation coming from Lombok.

Anyhow, is there a intention (not yet a plan) to unify this part of our 
code?

Best,
Łukasz

On 2.06.2023 08:35, chrisdutz (via GitHub) wrote:
> 
> GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?
> 
> And here ... even the Slf4j folks no longer recommend any general way of doing things: https://www.slf4j.org/faq.html#declared_static
> I guess in the past, there was a performance reason to to things, but this no longer seems to apply today.
> 
> GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6068178
> 
> ----
> This is an automatically sent email for dev@plc4x.apache.org.
> To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org
> 

Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?

And here ... even the Slf4j folks no longer recommend any general way of doing things: https://www.slf4j.org/faq.html#declared_static
I guess in the past, there was a performance reason to to things, but this no longer seems to apply today.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6068178

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl added a comment to the discussion: [Java] How should we handle "loggers"?

not having to write Boilerplate is also preventing bugs like writing getters and returning the wrong property...

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6222620

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?

Well you don't have to write boilerplate anyway as the IDE generates that for me .... So I do prefer that over having some tool generate stuff magically.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6226499

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?

Well admittedly I would be hesitant to use lombok as it requires our users to setup additional plugins in their development environments.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6218786

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?

Good point ... so there's a "almost not noticeable overhead" compared with a lot of new options, right?

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6069198

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "glcj (via GitHub)" <gi...@apache.org>.
GitHub user glcj added a comment to the discussion: [Java] How should we handle "loggers"?

Hello,

I think we don't use loombok in the project (pom.xml).

I think we should not add more libraries than necessary if it can be solved within the JDK tools.

My grain of sand

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6221233

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl added a comment to the discussion: [Java] How should we handle "loggers"?

a3ea768d2f7b35211d553505c9509b2c28a000d2 ([here](https://github.com/apache/plc4x/commit/a3ea768d2f7b35211d553505c9509b2c28a000d2#diff-29f99c8cd536dee245291d0c43c1db428fc4c628e4111670fb10d567c3ce18e1L188))

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6227060

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl added a comment to the discussion: [Java] How should we handle "loggers"?

With the up-rise of static loggers context became more relevant. So with that in mind it is pretty helpful to have loggers enriched and pass it down to the downstream objects which enrich them by themselfs with their context variables.
Recently in golang I moved to this pattern out of 3 reasons:

1. Have more control over the context
2. Easier way to configure them
3. Being able to assign those log statements to the relevant tests

Point 3 becomes painfully important once you move into async territory

So I would vote for having them instance bound.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6068466

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "foxpluto (via GitHub)" <gi...@apache.org>.
GitHub user foxpluto added a comment to the discussion: [Java] How should we handle "loggers"?

I would suggest for Java to use the notation `@Log4j2` present in Lombok to decrease the boilerplate an configure the logging notation externally as described here: [@Log (and friends)](https://projectlombok.org/features/log).

I voted for "log"

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6217888

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl edited a comment on the discussion: [Java] How should we handle "loggers"?

With the up-rise of structured loggers context became more relevant. So with that in mind it is pretty helpful to have loggers enriched and pass it down to the downstream objects which enrich them by themselfs with their context variables.
Recently in golang I moved to this pattern out of 3 reasons:

1. Have more control over the context
2. Easier way to configure them
3. Being able to assign those log statements to the relevant tests

Point 3 becomes painfully important once you move into async territory

So I would vote for having them instance bound.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6068466

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl edited a comment on the discussion: [Java] How should we handle "loggers"?

With the up-rise of structured loggers, context became more relevant. So with that in mind it is pretty helpful to have loggers enriched and pass it down to the downstream objects which enrich them by themselfs with their context variables.
Recently in golang I moved to this pattern out of 3 reasons:

1. Have more control over the context
2. Easier way to configure them
3. Being able to assign those log statements to the relevant tests

Point 3 becomes painfully important once you move into async territory

So I would vote for having them instance bound.

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6068466

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "chrisdutz (via GitHub)" <gi...@apache.org>.
GitHub user chrisdutz added a comment to the discussion: [Java] How should we handle "loggers"?

Would be awesome, if we could see who voted how :-/

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6170967

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "sruehl (via GitHub)" <gi...@apache.org>.
GitHub user sruehl added a comment to the discussion: [Java] How should we handle "loggers"?

I think in most IDEs it is enabled by default nowadays

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6218907

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org


Re: [D] [Java] How should we handle "loggers"? (plc4x)

Posted by "foxpluto (via GitHub)" <gi...@apache.org>.
GitHub user foxpluto added a comment to the discussion: [Java] How should we handle "loggers"?

@chrisdutz  It depends, if Lombok will  be used for more feature than the simple logs one, enabling the plugin in the IDE will be worth. Lombok is a great tool for  killing the Boiler Plate. 

GitHub link: https://github.com/apache/plc4x/discussions/973#discussioncomment-6219960

----
This is an automatically sent email for dev@plc4x.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@plc4x.apache.org