using ComponentPro.Diagnostics.XTrace

0
Hi, I want to activate xtrace log when I'm using ftp & sftp tools but on a specific way : dynamically, I can open 1 or more connections. when I open several connections at the same time, I want, for each connection , that the logs be recorded in one different file. (1 ftp session = 1 log file). each log will contain only logs related to "his associated connection" I created my own custom class . the philosophy is the following : public class MyCustomLog : ComponentPro.Diagnostics.UltimateTextWriterTraceListener { public String TraceFileName = null; public TextWriter _LogAppSession = null; public override void TraceData(object source, TraceEventType eventType, string category, string message) { this._LogAppSession.WriteLine("--->" message); } public int Init (String LogFile) { TraceFileName = LogFile; if (File.Exists(this.TraceFileName) == false ) { this._LogAppSession = TraceFileName.CreateText(false ); else this._LogAppSession = TraceFileName.AppendText(false ); } when I create the class for each ftp connnection : c_session_ftp = new ComponentPro.Net.Ftp(); logListner = new MyCustomLog (); logListner.Init (session_log); ComponentPro.Diagnostics.XTrace.Default.Level = ComponentPro.Diagnostics.TraceEventType.Verbose; ComponentPro.Diagnostics.XTrace.Default.Listeners.Add(session.logListner); but this does not work as I expected, the _LogAppSession is null an alternative was to use a static class and detect within tracedata the correct connection/log file i wanted to use the source value to detect the "related" connection but, until the "ftp" connection is "opened", the source value is null. how can be such a behavious (1 log file per connection ) be implemented ? many thanks for your help
 
asked 12/24/2020 3:03:03 PM
add a comment

1 Answers

0
problem solved made it differently
 
answered 1/1/2021 9:49:38 PM
add a comment

Your Answer

Not the answer you're looking for? Browse other questions tagged ftp sftp or ask your own question.