LogWriter.Write method

+1 vote
asked Dec 10, 2013 by Chew (370 points)
edited Dec 10, 2013

G'morning All,

I have a telnet session started where I specify a FileLogWriter, like so:

telnet = new Telnet(aixServerName, port);
telnet.LogWriter = new Rebex.FileLogWriter("./MyLog.log", Rebex.LogLevel.Verbose);
vt = telnet.StartVirtualTerminal();

Can I manually write my own messages to this log file ? If so, how ?

Thanks !


2 Answers

0 votes
answered Dec 10, 2013 by Chew (370 points)
edited Dec 10, 2013

I figured this out.

telnet.LogWriter.Write(Rebex.LogLevel.Info, null, 0, string.Empty, "Didn't Find the Expected Response: >|$ Prompt");

Thanks !


0 votes
answered Dec 10, 2013 by Tomas Knopp (58,890 points)
edited Dec 10, 2013


yes it is possible to write your own messages into the log file.

var client = new Telnet(server, port);
client.LogWriter = new Rebex.FileLogWriter("MyLog.log", Rebex.LogLevel.Verbose);

// you can write custom messages to the log using the LogWriter.Write method like this:
int instanceID;
client.LogWriter.Write(Rebex.LogLevel.Debug, typeof(Imap), instanceID, "MyArea", "MyMessage");

If you have just one instance of Telnet, just use instanceID = 0. If you are using multiple instances, you can use different instanceID's to differentiate it in the log file.