What is more fundamental, Logic or set theory? I am learning about the foundations of Mathematics, and I see that there are some theories which have their origins in preceding theories and so on. Now, this process must have an end. This end, is set theory or logic?
What is more fundamental, logic or set theory?
 A: The problem is that there's no single way to interpret "fundamental." Different mathematicians (including logicians), depending on their philosophical and possibly aesthetic stances, will support different approaches. A fascinating feature of mathematics is that it remains coherent despite this; I'll say more about this below.
To my mind the two simplest perspectives to understand - regardless of whether one finds either plausible - are (strong forms of) formalism and Platonism.
For a formalist, mathematics is essentially a game of symbols. The coherence of mathematics as a discipline arises from the existence of clear rules for this game, and this is really all that mathematics is in a sense. (Of course this leaves serious questions of explaining its applicability and interestingness, but that's not important right now.) To a formalist, the starting point of mathematics is therefore a clear presentation of the rules, and this amounts to a "syntax-only" approach to logic: we pin down a specific formal language and derivation system.
For a Platonist, there is a genuine "mathematical reality" and mathematical statements are either true or false. (As with the formalist position there are serious questions here - what does "mathematical reality" even mean, and how are we supposed to gain information about it? - but again that's not the point of this answer so I'll ignore it.) Here "fundamental" takes on an ontological flavor. A ($\mathsf{ZFC}$-)set-theoretic Platonist, for example, will take the stance that the "real mathematical universe" genuinely consists of sets satisfying the $\mathsf{ZFC}$ axioms, and in this sense set theory is the fundamental way of describing that universe. Proof theory, by contrast, emerges as a tool for reasoning about that universe - but ontologically speaking that's entirely separate.
And of course these are not the only positions out there. Common to all these stances, however, is a commitment to the intelligibility of mathematics granting only a very mild shared understanding. For the formalist this amounts to the fact that the rules of mathematics are easy to understand, regardless of whether one erroneously believes that they "mean" something; for the Platonist, this amounts to the idea that all of us somehow share some intuitive connection to the "mathematical universe," and even if we only think in terms of formal systems this connection will guide our choice of systems to study. We can see this in action whenever mathematicians of fundamentally different outlook work together to prove theorems, which happens all the time.

For what it's worth I largely side with formalism, but I find it extremely useful to be able to "try on" different positions at different times.
