The English -logy suffix originates with loanwords from the Greek, usually via Latin and French, where the suffix (-) is an integral part of the word loaned. E.g. astrology from astrologia, since the 16th century.
The French -logie is a continuation of Latin -logia, ultimately from Ancient Greek - (-logía). Within Greek, the suffix is an - (-ía) abstract from (lógos, "account, explanation, narrative"), itself a verbal noun from ? (lég?, "I say, speak, converse, tell a story").
Within English, the suffix becomes productive, especially to form names of sciences or departments of study, analogous to names of disciplines loaned from the Latin, such as astrology from astrologia or geology from geologia. Original compositions of terms with no precedent in Greek or Latin become common beginning in the later 18th century, sometimes imitating French or German templates (e.g. insectology, attested 1766, after French insectologie; terminology, attested 1801, after German Terminologie).
In a third stage, from the 19th century, the suffix becomes productive enough to form nonce combinations with English terms with no Greek or Latin origin, such as undergroundology (1820), hatology (1837).
Finally, from the second half of the 19th century, the suffix has also been used as a simplex as ology (plural ologies) and logy (plural logies), in parallel with and often alongside ism (plural isms).