ptv-logistics/Log4ALA

Log4ALA not supporting = character

ankitchourasiya opened this issue · 7 comments

There is issue with the LOG4ALA, if log messages contain the = character then it will break the format.Check the below samples.
Msg1: Test Message1
{"DateValue":"2018-09-13T06:27:47.8766332Z", "MiscMsg":"Test Message1","Logger":"Log4ALALogger","Level":"DEBUG"}
Msg2: Test Message1=
{"DateValue":"2018-09-13T06:27:47.8766332Z","Test Message1":"","Logger":"Log4ALALogger","Level":"DEBUG"}
Msg3: Test Message1=MSG
{"DateValue":"2018-09-13T06:38:34.1880660Z","Test Message1":"MSG","Logger":"Log4ALALogger","Level":"DEBUG"}
Msg4: Test Message1==
{"DateValue":"2018-09-13T06:30:20.6858601Z","MiscMsg":"Test","Logger":"Log4ALALogger","Level":"DEBUG"}
Msg5: Test Message1===
{"DateValue":"2018-09-13T06:32:39.5502050Z","MiscMsg":"Test Message1===","Logger":"Log4ALALogger","Level":"DEBUG"}
Msg6 Test Message1====
{"DateValue":"2018-09-13T06:33:56.5592493Z","MiscMsg":"Test Message1====","Logger":"Log4ALALogger","Level":"DEBUG"}

To recreate the issue just add the = character in the log message and check the result.
+Add: @moberacker

@moberacker : Thank you for quick response, Are we going to resolve this issue in next version? if so when is the next version release?. This issue is critical for us as we want it to store some user tokens in ALA which contains special character.

Hi @ankitchourasiya ,

is it possible for you to use the seaparators = and ; inside brackets like

"key_0[=]value_0[;]...[;]key_n[=]value_n"

instead of

"key_0=value_0;...;key_n=value_n"

?

Regards,
Markus

@moberacker:
Am to able to find out the workaround for the issue, now instead of
log.Debug("TestMessage=100"),
am sending the logs in below pattern,
log.Debug(new {Log= "TestMessage=100"})
so its storing the message ("TestMessage=100") in MiscMsg_Log_s column in ALA.
Still if we want to store the message in MiscMsg column that would not work if the message contain = or ; character, but that's fine for now, above workaround will resolve our problem.

Thank you for support!!.

Hi @ankitchourasiya,

ok now you use the log message as anonymous type which were mentioned under Use it. But in this case your message log.Debug(new {Log= "TestMessage=100"}) normally will be stored in Log_s and not MiscMsg_Log_s.

If you only need one custom field in Azur Log Analytics e.g. MiscMsg_s you could also try to set the property YOUR_APPENDER_NAME.keyValueDetection=false and all log messages log.Debug("TestMessage=100") will be stored in MiscMsg_s.

But in the next version it will be possible to configure any separators with the following properties:

  • keyValueSeparator e.g. with "[=]" or any other char or char array separator (default is "=")
  • keyValuePairSeparator e.g. with "[;]" or any other char or char array separator (default is ";")

now it's possible to store e.g TestMessage=100 in the Azure Log Analytics custom field with for example name Message_s with log.Debug("Message[=]TestMessage=100")

Regards.
Markus

@moberacker : Thank you this very helpful information!!
It's still storing the log message in MiscMsg_Log_s if am using
log.Debug(new {Log= "TestMessage=100"}) and that's fine.
Am closing this ticket as you mentioned above if will set YOUR_APPENDER_NAME.jsonDetection to false then it will not break the format.

Hi @ankitchourasiya,

sorry i mean YOUR_APPENDER_NAME.keyValueDetection=false.

Regards,
Markus