Java
Chilkat2 Java
Clear the IMAP Session Log
See more IMAP Examples
Demonstrates the Chilkat Imap.ClearSessionLog method, which clears the in-memory text returned by the SessionLog property. Session logging remains enabled or disabled according to the KeepSessionLog property. This example connects, logs in, and clears the log.
Background: When session logging is enabled, the
SessionLog accumulates the raw IMAP command/response dialog — the first thing to inspect when diagnosing a failure. Over a long-lived session that log grows continuously; ClearSessionLog resets it so you can capture just the exchange for the next operation of interest, rather than sifting through the entire history.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Imap;
public class ChilkatExample {
public static void main(String[] args) {
// Demonstrates the Imap.ClearSessionLog method, which clears the in-memory text returned by
// the SessionLog property. Session logging remains enabled or disabled according to the
// KeepSessionLog property.
Imap imap = new Imap();
imap.setSsl(true);
imap.setPort(993);
try {
imap.connect("imap.example.com");
imap.login("user@example.com", "myPassword");
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
// Clear the session log (for example, before the next operation you want to capture).
imap.clearSessionLog();
System.out.println("Session log cleared.");
try {
imap.disconnect();
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
}
}