JavaMoney / jsr354-ri

JSR 354 - Moneta: Reference Implementation
Other
344 stars 101 forks source link

toString() printing continueosly useless logs #361

Closed sixro closed 1 year ago

sixro commented 3 years ago

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

keilw commented 3 years ago

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 ;-)

sixro commented 3 years ago

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?

keilw commented 3 years ago

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 commented 3 years ago

@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".

sixro commented 3 years ago

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

keilw commented 3 years ago

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 commented 3 years ago

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.

sixro commented 3 years ago

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

butenkor commented 3 years ago

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?

keilw commented 3 years ago

@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.

martel commented 2 years ago

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

keilw commented 2 years ago

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?

commodis commented 1 year ago

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 commented 1 year ago

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:

My workaround was to put the moneta package logger on WARNING

echo 'org.javamoney.moneta.level = WARNING' >> $JAVA_HOME/conf/logging.properties
keilw commented 1 year ago

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 commented 1 year ago

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