First of all, I am a beginner in the field of Set Theory and my knowledge about Infinitary Logic is only at the informative level, so my questions might be nonsense.
One could think that, for any set $S$ whose elements are non-empty sets $S_i$ (with $i\in I$), there is a function taking any element of $S$ and giving an element of $S_i$. This is clear, because $S_i\not=\varnothing$, so, we can take some element from $S_i$.
That is the naive way of thinking, because it is useful only for finite sets. This is because first order logic is finitary. In particular, you can't ask your butler to pick a sock arbitrarily from each box if you have infinitely many boxes, it would take (at least) all of eternity to have one set of socks, one from each box. This is where the axiom of choice comes in, stating that it is possible to obtain such a set (although there is no way to explain it to the butler in finite time).
I needed that very basic introduction to be able to continue my reasoning. It seems natural to me that an infinitary logic would allow a rule to obtain a choice function for any set. For example, applying "$S_i$ is non-empty, so take some element from it" infinitely many times. But I read on wikipedia something about infinitary logic and they talk about the axiom of choice being required in some cases. So, my reasoning above is surely wrong.
Now I can formulate my questions. Why isn't it possible to do something like the above? Does infinitary logic work otherwise? Is there an infinitary logic in which it is possible? And, if so, is it an extension of usual first-order logic or something bizarre?
Thanks for your answers.
Edit: after the dialogue with Asaf, it seems convenient to clarify some things.
First, the goal is to obtain the axiom of choice as a theorem from a few axioms (such as $\mathsf{ZF}$) and the fact that an infinitary logic allows infinite formulas and this can be exploited to obtain a choice function for infinite sets (something similar to what is done with finite formulas to obtain choice functions for finite sets).
Second, the problem is perhaps too open, since a specific logic would have to be defined and some axioms introduced and, even if it were possible to do the above, the problems involved in using an infinitary logic are enormous.