danieleteti / loggerpro

An modern and pluggable logging framework for Delphi
Apache License 2.0
352 stars 91 forks source link

Is log ordered by tag? #55

Closed MoacirSchmidt closed 2 years ago

MoacirSchmidt commented 2 years ago

I would like to have log ordered by datetime instead of tag:

2022-06-17 08:38:47:672  [TID 41312   ][INFO      ] [RESPONSE  ] [200 (0ms)      ] GET /turma/35102/disciplina HTTP/1.1 
2022-06-17 08:38:47:703  [TID 21272   ][INFO      ] [RESPONSE  ] [200 (0ms)      ] GET /matricula?idTurma=35102&idDisciplina=11133 HTTP/1.1 
2022-06-17 08:38:47:766  [TID 15512   ][INFO      ] [RESPONSE  ] [200 (0ms)      ] GET /horario?idTurma=35102&idDisciplina=11133&somenteDatasComTarefa=false HTTP/1.1 
2022-06-17 08:38:49:859  [TID 25364   ][INFO      ] [RESPONSE  ] [200 (0ms)      ] OPTIONS /api/v1/atendimento/conversa?id_canal=25&id_pessoa=0&id_solicitante=0&id_atendente=333671&id_professor=0&data= HTTP/1.1 
2022-06-17 08:38:51:250  [TID 11616   ][INFO      ] [RESPONSE  ] [200 (0ms)      ] GET /api/v1/atendimento/conversa?id_canal=25&id_pessoa=0&id_solicitante=0&id_atendente=333671&id_professor=0&data= HTTP/1.1 InUse: True
2022-06-17 08:34:33:270  [TID 27088   ][DEBUG     ] [SQL       ] Debug connection: ; ThreadId: 27088; InUse: True
2022-06-17 08:34:33:270  [TID 27088   ][DEBUG     ] [SQL       ] Debug connection: ; ThreadId: 27088; InUse: True
2022-06-17 08:34:33:286  [TID 27088   ][DEBUG     ] [SQL       ] Debug connection: ; ThreadId: 27088; InUse: True
danieleteti commented 2 years ago

Logs are ordered by "arriving time" not by tags.

Did I get the point?

Il giorno ven 17 giu 2022 alle ore 13:44 Moacir Schmidt < @.***> ha scritto:

I would like to have log ordered by datetime instead of tag:

2022-06-17 08:38:47:672 [TID 41312 ][INFO ] [RESPONSE ] [200 (0ms) ] GET /turma/35102/disciplina HTTP/1.1 2022-06-17 08:38:47:703 [TID 21272 ][INFO ] [RESPONSE ] [200 (0ms) ] GET /matricula?idTurma=35102&idDisciplina=11133 HTTP/1.1 2022-06-17 08:38:47:766 [TID 15512 ][INFO ] [RESPONSE ] [200 (0ms) ] GET /horario?idTurma=35102&idDisciplina=11133&somenteDatasComTarefa=false HTTP/1.1 2022-06-17 08:38:49:859 [TID 25364 ][INFO ] [RESPONSE ] [200 (0ms) ] OPTIONS /api/v1/atendimento/conversa?id_canal=25&id_pessoa=0&id_solicitante=0&id_atendente=333671&id_professor=0&data= HTTP/1.1 2022-06-17 08:38:51:250 [TID 11616 ][INFO ] [RESPONSE ] [200 (0ms) ] GET /api/v1/atendimento/conversa?id_canal=25&id_pessoa=0&id_solicitante=0&id_atendente=333671&id_professor=0&data= HTTP/1.1 InUse: True 2022-06-17 08:34:33:270 [TID 27088 ][DEBUG ] [SQL ] Debug connection: ; ThreadId: 27088; InUse: True 2022-06-17 08:34:33:270 [TID 27088 ][DEBUG ] [SQL ] Debug connection: ; ThreadId: 27088; InUse: True 2022-06-17 08:34:33:286 [TID 27088 ][DEBUG ] [SQL ] Debug connection: ; ThreadId: 27088; InUse: True

— Reply to this email directly, view it on GitHub https://github.com/danieleteti/loggerpro/issues/55, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK4ZJAYOBO4R6BUYKBETI3VPRQKBANCNFSM5ZCAXH3A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Daniele Teti CEO & CTO bit Time Professionals website [it]: www.bittimeprofessionals.it website [en]: www.bittimeprofessionals.com blog: www.danieleteti.it ​my last book on leanpub https://leanpub.com/delphimvcframework​ my​ previous​ books on amazon https://www.amazon.it/s?i=stripbooks&rh=p_27%3ADaniele+Teti mobile: +39 3496626822 office: +39 06 20761499

MoacirSchmidt commented 2 years ago

As you can see above, the log entry at 08:38:51 appears BEFORE log entry at 08:34:53.

The tags are different between then so i suppose it may be related...

Of course I expected to have log ordered by "arriving time" also :-)

Did i miss something?

danieleteti commented 2 years ago

22-06-17 08:38:51:250 [TID 11616 ][INFO ] [

That happend becouse the log items comes from different threads. The time stamp is related to the original time of log generation (the time in the thread). Then the OS can pause the thread and then you see an older message in the file before a more recent one. That's how the threads works. If you need to analize by timestamp, I suggest you to use one of the appenders which use database or elastic or csv or other media which can be ordered by columns.

MoacirSchmidt commented 2 years ago

Thank you very much for clarifying, @danieleteti and congratulations for your excellent work!

MoacirSchmidt commented 2 years ago

Sorry for boring you again, @danieleteti but I realize that if i use the same TAG for all threads the log is ordered by "arriving time" as desired regardless of thread it is coming from. I will try this approach and put TAG into message.

Do you think this may lead me to problems in the future?