jsr354-ri icon indicating copy to clipboard operation
jsr354-ri copied to clipboard

toString() printing continueosly useless logs

Open sixro opened this issue 4 years ago • 11 comments

Hi, I was using the library in an app where I need to examine logs and I have seen the messages printed in Money.defaultFormat() such as:

    [...]
    Logger.getLogger(Money.class.getName()).info("Using default formatter for toString().");
    [...]

What should I do with those logs? They are pretty useless to me... it seems they are mostly for debug... Regards

sixro avatar Jun 24 '21 19:06 sixro

I thought this was already mentioned in a different issue ticket, but thanks for pointing directly to it here. As deployment to MavenCentral works now, but we still have to migrate away from the now disabled travis-ci.org to something else, therefore please bear with us unless you would like to help with the CI build migration ;-)

keilw avatar Jun 24 '21 19:06 keilw

Thanks for the answer @keilw.
I didn't know you were having issues due to travis-ci.org.
Did you consider the free plan provided by travis-ci.com or you can't use it for other reasons?

sixro avatar Jun 24 '21 20:06 sixro

I thought it was automatically migrated but it seems only some other projects I tried to migrate earlier were. As long as it's free I guess we'll give it a try. To verify some of the issues around MavenCentral deployment I also created https://github.com/JavaMoney/javamoney-parent/actions for javamoney-parent, so there would be an alternative to travis-ci.com should we have problems with the quota or similar.

keilw avatar Jun 24 '21 20:06 keilw

@sixro Seems we're stuck at travis-ci.org forever and cannot use travis-ci.com anymore because none of the repositories that were on the old org are allowed to migrate over. ;-/ They are invisible even after trying to connect travis-ci.com to the JavaMoney organization, so we cannot use Travis-CI anymore except maybe for a few exotic repos here like "Midas".

keilw avatar Jun 25 '21 17:06 keilw

Thanks for the update @keilw Very sad to hear that.

sixro avatar Jun 25 '21 17:06 sixro

We'll see what Travis-CI says and if they are supportive, otherwise we'd use another alternative like CircleCI which works fine for other projects like https://github.com/unitsofmeasurement. There could be a fix via #349 but need to verify, if the author is a JCP member or not.

keilw avatar Jun 25 '21 17:06 keilw

After jumping many hoops and filling out things multiple times and a manual import of the old travis-ci.org settings it seems the new one might be working. As long as we don't run out of credit soon (I have no idea if that's per organization or just for me as the owning user?) let's give it a try, but for some e.g. javamoney-parent we may also use GH-actions as a backup or alternative.

keilw avatar Jun 26 '21 16:06 keilw

Hi @keilw good to know, thanks.
I am using Github Actions in a private project and I am quite happy with that.

sixro avatar Jun 26 '21 19:06 sixro

It seem that this logging has been introduced with version 1.4 and now produces a lot of spam in the logs. Any suggestion how it can be suppressed or you plan to remove those once travis build works again?

butenkor avatar Aug 31 '21 15:08 butenkor

@butenkor There is a bigger problem with the whole config stuff in Moneta and we could be forced to wait till Jakarta EE releases the first Config spec (since everything prior to that including MP Config was just a temporary solution and not stable enough in the long term) but as soon as that is resolved we hope to release at least a 1.4.3 build.

keilw avatar Aug 31 '21 15:08 keilw

Hi. Is this going to get fixed anytime soon? It's being printed on every single FastMoney.toString() call.

One simple change I would suggest is to drop the log if the property is already set by the user. Another one would be to print the notice only once on the class initialization instead of each toString() call. Maybe from the MonetaryConfig itself?

At the same time I would suggest reusing the logger from the FastMoney. Why is it requesting a new logger each time?

I can contribute a pull request if needed. I just would like not to spend time writing it if its not going to get used:

https://github.com/JavaMoney/jsr354-ri/blob/32eae4917c10f3415f7ace619811c1ae0bbf1cc4/moneta-core/src/main/java/org/javamoney/moneta/FastMoney.java#L662-L668

martel avatar Jan 05 '22 00:01 martel

Hi. Is this going to get fixed anytime soon? It's being printed on every single FastMoney.toString() call.

It is only printed on the fine level, so where did that get applied?

keilw avatar Nov 07 '22 18:11 keilw

the problem is, that the latest release is 1.4.2 and the logging is using info

https://github.com/JavaMoney/jsr354-ri/blob/1.4.2/moneta-core/src/main/java/org/javamoney/moneta/FastMoney.java#L663-L666

commodis avatar Jan 02 '23 13:01 commodis

It seem that this logging has been introduced with version 1.4 and now produces a lot of spam in the logs. Any suggestion how it can be suppressed or you plan to remove those once travis build works again?

Moneta uses the java.util.logging framework. Thus the logging needs to be configured either:

  • through the JVM distribution $JAVA_HOME/conf/logging.properties, or
  • your own configuration file which needs to be set as a JVM option -Djava.util.logging.config.file=/tmp/logging.properties

My workaround was to put the moneta package logger on WARNING

echo 'org.javamoney.moneta.level = WARNING' >> $JAVA_HOME/conf/logging.properties

commodis avatar Jan 09 '23 11:01 commodis

This should be fixed in the code already but thanks for the workaround @commodis because there are still a few other issues before we can publish 1.4.3.

keilw avatar Jan 09 '23 20:01 keilw

That should be fixed for some time now. Also changed several other usages of info to config level which seems more appropriate.

keilw avatar Feb 12 '23 15:02 keilw