https://learninghub.kx.com/forums/topic/error-while-logging-in-kx-api-code
var1:first exec sum smb from select smb1;
.log.LOG.info(“log SampleMean %s”;string var1);
when trying to log with code :.log.LOG.info(“log SampleMean %s”;string var1); HDB and some process is not coming post restart. seems like conversion error. please advise
Can you explain more clearly what you're trying to do and the error you are receiving?
Hi iodwyer- Thanks for your reply, I'm trying the below code, if var1 is having a number or decimal value, how can we print in in logfile say as its HDB process I would like to print the value of var1 in HDB logs. I tried below Loging code but unfortunately it didn't work. there are no specific error.
var1:first exec sum smb from select smb1;
.log.LOG.info(“log SampleMean %s”;string var1);
See example below, hopefully this helps.
ubuntu@ian-dev:~$ q KDB+ 4.1 2025.04.28 Copyright (C) 1993-2025 Kx Systems l64/ 4()core 15990MB ubuntu ian-dev.firstderivatives.com 127.0.1.1 EXPIRE 2025.07.13 iodwyer@kx.com KXAI #84167 q).com_kx_log.init[:fd://stdout
:fd:///tmp/app.log; ``] 8c6b8b64-6815-6084-0a3e-178401251b68 5ae7962d-49f2-404d-5aec-f7c8abbae288 q).log.LOG:.com_kx_log.new[`Test; ()] q).log.LOG.info (“log SampleMean %1”; 10) {“time”:“2025-06-12T00:03:13.532z”,“component”:“Test”,“level”:“INFO”,“message”:“log SampleMean 10”} \ ubuntu@ian-dev:~$ cat /tmp/app.log {“time”:“2025-06-12T00:03:13.532z”,“component”:“Test”,“level”:“INFO”,“message”:“log SampleMean 10”}
iodwyer:
fd:///tmp/app.log
Thanks for providing the solution. I’m able to log the float or string variable values. But what would be the way to log a dictionary result or a vector result. also is there we can debug the KX API code so that we could trace the runtime values?
while trying to log result with code :
res:1#.q; / Setup result dictionary
.log.LOG.info("INC0615027-calculated res is %l";res);
getting below error:
.utils.loadfile[1] ~
/apps/kx/delta-data/DeltaControlData/qsrc/nxProcess.q:44[2] .utils.loadfile[`$qsrcdir,“/DS_RTE.q”]
^
\l /apps/kx/delta-data/DeltaControlData/qsrc///nxProcess.q
^
.utils.i.loadfile[1] ~
.ex.loadprocess[1] ~
.trp.i.executeCatch[1] ~
.ex.tryload[0] ~
/apps/kx/delta-data/DeltaControlData/temp/unlocked/prcl_4190867_73037704.q:1[0] res:.ex.tryload
^
\l /apps/kx/delta-data/DeltaControlData/temp/unlocked/prcl_4190867_73037704.q
^
.utils.runUnlocked[1] ~
.utils.runUnlocked "res:.ex.tryload[]";
^
2025.06.30 20:17:33.290 ERROR [kxsRDB_1] .ds.rte.initialStateFunct failed: “limit”
2025.06.30 20:17:33.290 ERROR [kxsRDB_1] Error loading file: (`/apps/kx/delta-data/DeltaControlData/qsrc/DS_RTE.q;“limit”)
Using a dictionary works on my end
q).log.LOG.info ("log SampleMean %1"; `a`b`c!1 2 3)
{"time":"2025-07-04T00:19:27.251z","component":"Test","level":"INFO","message":"log SampleMean `a`b`c!1 2 3"}
Are you sure the error isn’t coming from somewhere else?
Hi iodwyer - That really helped. Thanks. I’m able to see logs now but for longer logs its getting truncated. Is there a way to avoid truncation for longer logs. Please find below the logs that I’m getting
.log.LOG.info(“INC****-calcEntire entr %l”;entr);
2025.07.08 17:38:04.893 INFO [kxsQP_1] LOG {PYTHON-PROC-7311b2de-ff7c-4c4c-8bfd-90637626dc46} INC****-calcEntire entr +Date
chanIDts
DowWeekend
WeekdayHoliday
WkndOrHolTotal
ObservationsTime
sensorTSdow
holidaystratum
Period`Peak!(2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.01.01 2024.0..
mtsuno
July 8, 2025, 10:34pm
8
Hello,
You can increase the logging amount by changing the console size .
For example:
q)/ current size
q)\c
25 80i
q)100#10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10..
q)/ change to 200 200
q)\c 200 200
q)100#10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10..
q)
However, we generally would not recommend printing out such a large object as a log message, unless its for one-time debugging, as it will impact your performance.
Also, I see that you are a current user of our KX Sensors product. You can feel free to ask these types of product how-to questions on our support portal as well, where each ticket is bounded by SLAs so you can get more prompt responses.
Thanks!
Max
Thank you, Max. This helped and these large logs are just for debugging purpose. Will post the further questions in KX support portal