BUCHAREST, Rumania, Nov. 21— Several thousand rioting workers ransacked the city hall in the industrial city of Brasov last Sunday, driven to the streets by severe pay cuts and the prospect of a third consecutive winter of food and energy shortages.

It was the first major industrial violence since coal miners went on strike 10 years ago, and the first ripple of discontent over drastic national policies praised by economists here as designed to boost productivity and eliminate almost all Rumanian foreign debt by 1990. A Rumanian familiar with the events said the workers marched on city hall from factories where they had gathered to vote in local elections, protesting a decision by party officials to enforce laws mandating pay cuts for unfulfilled production quotas. Factories Missed Quota

The big tractor and truck works in Brasov, roughly 100 miles north of Bucharest, were 20 percent under quota in October, and wages were to be cut equivalently.

Rumanian newspapers ignored the riots, but there were reports that food supplies had subsequently been increased. An editorial in the Monday edition of Scinteia, the party newspaper, while omitting any mention of Brasov, slapped the fingers of local officials, calling for ”fruitful cooperation between citizens and elected officials.”

Diplomatic specialists blamed the production shortfalls in Brasov on the kind of shortages and mismanagement that helped produce a third year of acute energy shortages.

This month, the Government ordered a 30 percent cut in energy use in homes and ”non-productive industries,” a term Rumanians said evidently applied to institutions such as schools and hospitals. The effects are visible everywhere in barely heated and dimly lit homes and public places. Street lights burn only on major thoroughfares, spreading an aura of obscurity about the city. Television is restricted to two hours in the evening. Theater productions, concerts and the opera begin at 6 P.M. Brave audiences bundle in scarves and overcoats in unheated theaters, and orchestra members wear fingerless gloves. A Policy of Austerity

In a broader sense, though, the shortages are the result of the resolve of the 69-year-old President, Nicolae Ceausescu, to repay all of the country’s foreign debt, accumulated by costly and uneconomical industrial investments during his early years in power. Since 1981, Rumania has more than halved its debt, to about $5.5 billion. To do so, it has run up six consecutive annual trade surpluses, the last, in 1986, of $2 billion. Rumanian economists suggest this was primarily the result of increased exports that resulted from timely investment in the production of higher-value manufactured goods, such as electronic components, fine mechanical products and computer-driven machinery.

But trade statistics show that much of the surplus came at the price of a basic disregard for consumer needs and, at times, for supplies for industry. While exports rose 11.6 percent in 1986, imports fell 5.6 percent.

Moreover, business people and diplomats say, much of the energy crisis is due to bad planning and to coal-driven generating stations that often do not work because of poor design and lack of spare parts and maintenance. Except for the outburst in Brasov, voices of discontent are barely whispered. With television broadcasts limited, Rumanians flock to the theaters. In one recent production, the audience laughed heartily as actors mimicked industry managers involved in the complex rite of preparing instant coffee. Few Rumanians ever see instant coffee.

Again, in a student theater in Iasi, near the Soviet border, visitors reported peals of laughter when a woman on stage picked up a phone to order meat from a butcher. Staples such as ham, salami and canned meats are now only found for hard currency, which Rumanians, unlike citizens of other Eastern bloc countries, are still forbidden to hold.