I was trying to grep a value by key from log4j file, the script works fine, is there anyway to include the timestamp to the output as well?
My script is:
awk '/duration=/ {print $4}' mylog.log | awk '{print substr($1, 10, length($1)-10)}' | less
the log file is:
WARN [20.07.22 00:02:43.647] TaskManager .process() Processing task took longer than set threshold
|-| |-| delayEvent=DelayEvent{eventName='UpdateUser', duration=65, endTime=1658275363647, averageValue=0, maxValue=637} | delayThreshold=50
|-| nanos=45293222359715481 | threadId=523 | threadName=ThreadManager | timestamp=1658275363647 | mid=nag1uu-1#42616
|-| layer=BAA |-| [ SISS]
WARN [20.07.22 00:02:44.689] TaskManager .process() Processing task took longer than set threshold
|-| |-| delayEvent=DelayEvent{eventName='UpdateUser', duration=88, endTime=1658275364689, averageValue=0, maxValue=637} | delayThreshold=50
|-| nanos=45293223401808770 | threadId=523 | threadName=ThreadManager | timestamp=1658275364689 | mid=nag1uu-1#42616
|-| layer=BAA |-| [ SISS]
output is
65
88
My expected result is:
20.07.22 00:02:43.647 65
20.07.22 00:02:44.689 88
Is there anyway to achieve this? Thanks a lot in advance.