I’m trying to debug my custom javamail IMAPCommands.
In the process of constructing the command to send to the IMAP server, I do something like this:
public Object doCommand(IMAPProtocol p) throws ProtocolException {
Argument args = new Argument();
Argument sortCrit = new Argument();
sortCrit.writeString("REVERSE");
sortCrit.writeString("DATE");
args.writeArgument(sortCrit);
args.writeString("UTF-8");
Argument from1 = new Argument();
from1.writeString("FROM");
from1.writeString(searchFrom.get(0));
Argument from2 = new Argument();
from2.writeString("FROM");
from2.writeString(searchFrom.get(1));
fromArg.writeString("OR");
fromArg.writeArgument(from1);
fromArg.writeArgument(from2);
args.writeArgument(fromArg);
Response[] r = p.command("UID SORT", args);
Response response = r[r.length - 1];
[...]
}
I want to log (say, to stderr) what will be sent to the server with p.command. How do I do that?
Call session.setDebug(true) and you’ll get an entire protocol trace on System.out. That will show you what you’re actually sending.