The discussion on the basis of mathematics was mainly at the end of 19 and the beginning of the 20th century. At that time, there were many schools of thought about mathematics, one of which was the school of logicism, which believed that mathematics could be obtained completely through logic. However, some profound achievements in mathematical logic (such as Godel's incompleteness theorem) later denied this view. In fact, mathematics cannot be completely obtained by logic, that is to say, if mathematics is required to be non-contradictory, then it cannot be complete.
At present, the mainstream view of mathematics comes from Hilbert's formalism mathematics. Roughly speaking, it is an axiomatic view. In other words, people can set out from reality (or fantasy) and give a set of axioms that are not contradictory and unnecessary. Under this axiomatic system, a kind of mathematics is formed (just like what Hilbert himself did in Geometry Foundation). What happens after the axiom is established belongs to logic.
The main difference between formalism and logicism is that logicism regards mathematics as finite, and we can get all the mathematics we study from limited logical rules; But formalism holds that mathematics can be infinitely expanded (by establishing new axioms).
Therefore, logic is an important method and foundation of mathematics, but it is not the whole of mathematics.
On the contrary, mathematics does not include all logic. Logic is mainly (at least once) a branch of philosophy, which not only studies the deductive relationship of logical propositions, but also studies why this relationship is right, and so on. In logic, formal logic and mathematical logic mainly affect mathematics, but the part involving philosophical speculation does not belong to mathematics.