RestComm / smscgateway

RestComm SMS Gateway (SMSC) to send/receive SMS from/to Operators Network (GSM)
http://www.restcomm.com/
GNU Affero General Public License v3.0
127 stars 111 forks source link

remove SMS's non printable in server.log #250

Closed nhanth87 closed 6 years ago

nhanth87 commented 7 years ago

Nonprintable characters make line break in server.log they make log monitoring and parser more difficult. We can consider to remove them when logging to server.log

Follow zendesk 34607

Br, TN

nhanth87 commented 7 years ago

remove nonprintable character require checking every character in the SMS body, it will make highload

vetss commented 7 years ago

We have many such logging records. Better to point concrete examples that we need to update if we know such examples.

nhanth87 commented 7 years ago

It's a code that caught line break (because of \n)

        logger.severe(String.format("\nonPduRequestTimeout : targetId=" + smsSet.getTargetId()
                + ", PduRequestTimeout=" + event));
KeithMilner commented 7 years ago

I have examples of this from binary messages, for example, from cdr.log:

_2017-09-14 16:07:11,700 DEBUG [org.mobicents.smsc.library.CdrGenerator] 2017-09-14 16:07:11.544,XXXXXXXXXX,1,1,YYYYYYYYYY,1,1,successesme,SMPP,message,gateway1,3346224,,null,null,null,null,null,null,2,6,null,0,0,,,,,"**5I▒1dL ▒0`@I",""**

From server.log:

_Sent deliverSm to ESME: Test1, msgNumInSendingPool: 0, sms=SmsEvent [SmsSet=SmsSet [destAddrTon=1, destAddrNpi=1, destAddr=YYYYYYYY, networkId=6, destClusterName=test, destSystemId=test, destEsmeId=Test1, imsi=null, locationInfoWithLMSI=null, correlationId=null, inSystem=0, inSystemDate=null, dueDate=null, dueDelay=0, status=null, type=SMS_FOR_ESME, lastDelivery=null, alertingSupported=false, markedSmsAsDelivered=1, smsCount=1], dbId=b47cf12a-3c4a-4703-8efa-7c229f742562, dueSlot=0, stored=false, storingAfterFailure=true, invokedByAlert=false, sourceAddrTon=1, sourceAddrNpi=1, sourceAddr=XXXXXXX, origNetworkId=2, messageId=3346224, moMessageRef=0, origSystemId=gateway1, origEsmeName=NowSMS_1, submitDate=2017-09-14 16:07:11.544, deliverDate=null, serviceType=, esmClass=0, protocolId=0, priority=0, registeredDelivery=1, replaceIfPresent=0, dataCoding=4, nationalLanguageSingleShift=0, nationalLanguageLockingShift=0, defaultMsgId=0, scheduleDeliveryTime=null, validityPeriod=Sun Sep 17 16:07:11 UTC 2017, origMoServiceCentreAddressDA=null, deliveryCount=1, reroutingCount=0, originationType=SMPP, originatorSccpAddress=null, shortMessageText=**5I▒1dL ▒0`@If ▒I▒MJ$G

FTA& ▒4`P1

2dH#7 A "F ▒0`@ 0**, tlvSet=TlvSet []]_

A good approach would seem to be to wrap the output with a function which strips out non-printable characters. There are some examples at https://stackoverflow.com/questions/6198986/how-can-i-replace-non-printable-unicode-characters-in-java

olenara commented 6 years ago

Fixed by: 2dcb45ddc5a7f9cbf85258a5ff80ebd468ae874e c102fc9b69350dc4e042ef5cf55a1e2449cd3eaf