  This is the first of two papers in which we study the modular invariance of
pseudotraces of logarithmic intertwining operators. We construct and study
genus-one correlation functions for logarithmic intertwining operators among
generalized modules over a positive-energy and $C_2$-cofinite vertex operator
algebra $V$. We consider grading-restricted generalized $V$-modules which admit
a right action of some associative algebra $P$, and intertwining operators
among such modules which commute with the action of $P$ ($P$-intertwining
operators). We obtain duality properties, i.e., suitable associativity and
commutativity properties, for $P$-intertwining operators. Using pseudotraces
introduced by Miyamoto and studied by Arike, we define formal $q$-traces of
products of $P$-intertwining operators, and obtain certain identities for these
formal series. This allows us to show that the formal $q$-traces satisfy a
system of differential equations with regular singular points, and therefore
are absolutely convergent in a suitable region and can be extended to yield
multivalued analytic functions, called genus-one correlation functions.
Furthermore, we show that the space of solutions of these differential
equations is invariant under the action of the modular group.
