word-forming element meaning "a speaking, discourse, treatise, doctrine, theory, science," from Greek -logia (often via French -logie or Medieval Latin -logia), from -log-, combining form of legein "to speak, tell;" thus, "the character or deportment of one who speaks or treats of (a certain subject);" from PIE root *leg- (1) "to collect, gather," with derivatives meaning "to speak (to 'pick out words')." Often via Medieval Latin -logia, French -logie. In philology "love of learning; love of words or discourse," apology, doxology, analogy, trilogy, etc., Greek logos "word, speech, statement, discourse" is directly concerned.
The -ish in verbs (abolish, establish, finish, punish, etc.) is a mere terminal relic from the Old French present participle.
noun word-forming element, "that which is written or marked," from Greek gramma "that which is drawn; a picture, a drawing; that which is written, a character, an alphabet letter, written letter, piece of writing;" in plural, "letters," also "papers, documents of any kind," also "learning," from stem of graphein "to draw or write" (see -graphy). Some words with it are from Greek compounds, others are modern formations. Alternative -gramme is a French form.
From telegram (1850s) the element was abstracted by 1959 in candygram, a proprietary name in U.S., and thereafter put to wide use as a second element in forming new commercial words, such as Gorillagram (1979), stripagram (1981), and, ultimately, Instagram (2010). The construction violates Greek grammar, as an adverb could not properly form part of a compound noun. An earlier instance was the World War II armed services slang latrinogram "latrine rumor, barracks gossip" (1944).