Grammar is the mechanics of a language;
Logic (or dialectic) is the "mechanics" of thought and analysis;
Rhetoric is the use of language to instruct and persuade.
Sister Miriam Joseph described the three parts of the Trivium thus:
Logic is the art of thinking;
Grammar, the art of inventing symbols and combining them to express thought;
and Rhetoric, the art of communicating thought from one mind to another, the adaptation of language to circumstance.
Another description is:
Logic is concerned with the thing as-it-is-known,
Grammar is concerned with the thing-as-it-is-symbolized, and
Rhetoric is concerned with the thing-as-it-is-communicated.
The study of logic, grammar and rhetoric was considered preparatory for the quadrivium,
which was made up of arithmetic, geometry, music, and astronomy.
The trivium was the beginning of the liberal arts.
At many medieval universities this would have been the principal undergraduate course.
However, the contrast between the simpler trivium and more difficult quadrivium gave rise to the word "trivial".
Grammar, as an introducton to the texts of instruction, must necessarily be studied first.
Logic follows naturally, since its same analytic tools are employed in the form of poetic devices of Rhetoric.