0
我剛剛發現log4j在我的應用程序中打印浮點數爲指數(例如:2.2388E2)。我希望它顯示爲非指數的值。 (223.88)log4j打印浮點數爲指數
這種情況發生在客戶環境中,我可以模擬。在什麼情況下會發生這種事情?任何想法如何防止這一點?
其他信息:信封文檔是使用CXF生成的,如果它確實很重要。
下面是我的單位爲例:
@Test
public void testSomething()
{
ServiceEnvelopeDocument serviceEnvelopeDocument = ServiceEnvelopeDocument.Factory.newInstance();
ServiceEnvelope serviceEnvelope = serviceEnvelopeDocument.addNewServiceEnvelope();
ServiceBody serviceBody = serviceEnvelope.addNewServiceBody();
RsDetail rsDetails = serviceBody.addNewRsDetail();
float testFloat = 223.88f;
AuxiliaryAccountStaticBalanceDetail accountStaticBalance = rsDetails.addNewAuxiliaryAccountStaticBalanceDetail();
accountStaticBalance.setAccountBalance(testFloat);
logger.error(""+accountStaticBalance);
logger.error(serviceEnvelopeDocument.toString());
logger.error(String.valueOf(accountStaticBalance));
}`
輸出上面的源代碼:
2013-01-02 14:55:33.443 ERROR (main) AccountInquiryUtilTest: - <AccountBalance xmlns="http://schemas.ocbc.com/soa/emf/account/elements">223.88</AccountBalance>
2013-01-02 14:55:33.465 ERROR (main) AccountInquiryUtilTest: - <ServiceEnvelope xmlns="http://schemas.ocbc.com/soa/emf/common/envelope/" xmlns:cbs="http://schemas.ocbc.com/soa/emf/service/CBS-CustAccountInfo-I" xmlns:agg="http://schemas.ocbc.com/soa/emf/account/aggregates" xmlns:elem="http://schemas.ocbc.com/soa/emf/account/elements">
<ServiceBody>
<cbs:RsDetail>
<agg:HolderAccountTypeDetail/>
<agg:AuxiliaryAccountStaticBalanceDetail>
<elem:AccountBalance>223.88</elem:AccountBalance>
</agg:AuxiliaryAccountStaticBalanceDetail>
</cbs:RsDetail>
</ServiceBody>
</ServiceEnvelope>
2013-01-02 14:55:33.544 ERROR (main) AccountInquiryUtilTest: - <AccountBalance xmlns="http://schemas.ocbc.com/soa/emf/account/elements">223.88</AccountBalance>
輸出在客戶環境:
<ns3:AccountBalance>2.2388E2</ns3:AccountBalance>
你可以分享log4j配置嗎? –