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)
public int Init (String LogFile)
TraceFileName = LogFile;
if (File.Exists(this.TraceFileName) == false )
this._LogAppSession = TraceFileName.CreateText(false );
this._LogAppSession = TraceFileName.AppendText(false );
when I create the class for each ftp connnection :
c_session_ftp = new ComponentPro.Net.Ftp();
logListner = new MyCustomLog ();
ComponentPro.Diagnostics.XTrace.Default.Level = ComponentPro.Diagnostics.TraceEventType.Verbose;
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