danieleteti/loggerpro

Is log ordered by tag?

MoacirSchmidt opened this issue · 5 comments

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

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?

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.

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

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?