Call the logicians A, B, C, and D, in the order they speak. WLOG, say A is wearing a white hat. Note that each logician sees 2 black, 1 white if he's wearing white or 2 white, 1 black if he's wearing black, so he always knows his own hat is either [the colour it actually is] or red.
A is wearing white and sees 2 black, 1 white. As far as he knows, he could be wearing either white or red. He says, "I don't know."
Case 1: B is also wearing white
B is wearing white and sees 2 black, 1 white. If B were wearing red, then A (seeing 2 black, 1 red) would have been able to identify his own colour. So B says, "My hat is white."
C is wearing black and sees 2 white, 1 black. If C were wearing red, then B (seeing 1 white, 1 black, 1 red) would still have known his hat was white, since B wearing black would be inconsistent with A's answer (A would then have seen 1 red and 2 black and known he was wearing white). So C says, "I don't know."
D is wearing black and sees 2 white, 1 black. If D were wearing red, then C would have seen 1 red and 2 white and known his own colour. So D says, "My hat is black."
A is still wearing white, and argues as follows. If A were wearing red, then B would have seen 2 black, 1 red and known B was wearing white; C would have seen 1 black, 1 red, 1 white and known C was wearing black (if C were white, B would have seen 1 white, 1 black, 1 red and either black or white for B would have been consistent with A's answer); contradiction, so A says, "My hat is white."
In this case, the answer is C.
Case 2: B is wearing black, C is wearing white
B is wearing black and sees 2 white, 1 black. If B were wearing red, then A would have seen 1 black, 1 white, 1 red and still said "I don't know". So B says, "I don't know."
C is wearing white and sees 2 black, 1 white. If C were wearing red, A would have seen 2 black, 1 red and known his own colour. So C says, "My hat is white."
D is wearing black and sees 2 white, 1 black. If D were wearing red, B would have seen 2 white, 1 red and known his own colour. So D says, "My hat is black."
A is still wearing white, and argues as follows. If A were wearing red, then B would have seen 1 white, 1 black, 1 red and either black or white for B would have been consistent with A's answer; C would have seen 2 black, 1 red, and known C was wearing white; D would have seen 1 white, 1 black, 1 red and known that he was wearing black (if D were white, B would have seen 2 white, 1 red and known B was wearing black). So A says, "I don't know."
B is still wearing black, and argues as follows. If B were wearing red, then A would have seen 1 white, 1 black, 1 red and not known his own colour; B would have said what he did; C would have seen 1 white, 1 black, 1 red and known he was wearing white (if C was wearing black, A would have seen 2 black, 1 red and known his own colour); D would have seen 2 white, 1 red and known he was wearing black; and finally A would still not have known his colour (if A was wearing black, everything would have happened the same way it did!). So B says, "I don't know."
C and D still know their colours.
A is still wearing white, and argues as follows. If A were wearing red, then as above, B, C, D, and A (second time round) would still have responded as they did, and then B (seeing 1 white, 1 black, 1 red) would still not have known his own colour (if B were wearing white, then we have RWWB and everything goes through as before!) So A says "I don't know" for the third time.
B is still wearing black and argues as follows. If B were wearing red, then as above, the first and second rounds would have gone as they did, and then A (seeing 1 white, 1 black, 1 red) would still not have known his own colour (if A were wearing black, then we have BRWB and everything goes through as before!). So B says "I don't know" for the third time.
The same argument goes on. No new information is gained by anyone.
Case 3: B and C are both wearing black
As argued above, B is wearing black and says, "I don't know."
C is wearing black and sees 2 white, 1 black. If he were wearing red, B would have seen 2 white, 1 red and known his own colour. So C says, "My hat is black."
D is wearing white and sees 2 black, 1 white. If he were wearing red, A would have seen 2 black, 1 red and known his own colour. So D says, "My hat is white."
A is still wearing white, and argues as follows. If A were wearing red, then B would have seen 1 white, 1 black, 1 red and either black or white for B would have been consistent with A's answer; C would have seen 1 black, 1 white, 1 red, and known C was wearing black (if C were white, B would have seen 2 white, 1 red and known B was wearing black); D would have seen 2 black, 1 red and known that he was wearing white. So A says, "I don't know."
B is still wearing black, and argues as follows. If B were wearing red, then A would have seen 1 white, 1 black, 1 red and not known his own colour; B would have said what he did; C would have seen 2 white, 1 red and known he was wearing black; D would have seen 1 white, 1 black, 1 red and known he was wearing white (if D was wearing black, A would have seen 2 black, 1 red and known his own colour); and finally A would still not have known his colour (if A was wearing black, everything would have happened the same way it did!). So B says, "I don't know."
C and D still know their colours.
A is still wearing white, and argues as follows. If A were wearing red, then as above, B, C, D, and A (second time round) would still have responded as they did, and then B (seeing 1 white, 1 black, 1 red) would still not have known his own colour (if B were wearing white, then we have RWBW and everything goes through as before!) So A says "I don't know" for the third time.
B is still wearing black and argues as follows. If B were wearing red, then as above, the first and second rounds would have gone as they did, and then A (seeing 1 white, 1 black, 1 red) would still not have known his own colour (if A were wearing black, then we have BRBW and everything goes through as before!). So B says "I don't know" for the third time.
The same argument goes on. No new information is gained by anyone.
In Cases 2 and 3, A and B never find out their colours; C and D will just sit there snickering at them forever. But we're told in the OP that eventually "only one of them failed to name the color of his own hat", so we can deduce the following two pieces of information:
- the first two logicians to speak have the same colour of hat, as do the last two
- the third logician is the last one not to know his own colour.
This is the final answer.