0 votes

Looking at the notes on logging:
https://www.limilabs.com/blog/logging-in-mail-dll

It seems this is static/global. We have a multi user system and would like to be able to just record the logs specific to a certain user's usage of the component - is this possible?

by (450 points)

1 Answer

0 votes

Unfortunately this is not possible out-of-the box.

You could probably filter the logs using Thread.CurrentThread.ManagedThreadId and Log.WriteLine event.

by (301k points)
Could we make a feature request? It seems like something which should be available for multi user systems and something we have certainly seen in other components we use.
It is not possible to do that per user, as some client/server communication is done before user logs in. The only way of doing this would be per Imap/Pop3/Smtp instance which in fact is no much different than thread id filtering.
Per Imap/Pop3/Smtp sounds sensible and is essentially how other components do it (e.g. the FTP component we are using).

Not sure what you mean by ManagedThreadId, there is no reason to think that a particular context or user will be tied to a particular Thread ID.
I don't suppose you switch threads within a single IMAP session. You just need to remember the thread id when you create Imap instance and use that for filtering the logs in Log.WriteLine event handler.
Possibly, but sorry, this just sounds a bit hacky to me and not a pattern I have come across before.

I guess if you won't accept it as a feature request I will have to try your suggestion.

Otherwise we really like your component!
We accept that as a feature request - sorry for the misunderstanding.

I was just trying to help you solve your problem within the constraints of current library version.

We plan to add instance-id to the Log.WriteLine event and possibly additional WriteLine event on Imap/Pop3/Smtp instance - it's not yet fully decided.
No problem at all and thanks for considering the request.
...