The idea is indeed to Taylor expand the production function. To justify it, you can start with the constant elasticity of substitution function, which in the two-factor case can be written as
$$
Y = A[\alpha K^\gamma + (1 - \alpha)L^\gamma]^{1/\gamma} \tag{1}
$$
in this case $X_1 = K$, $X_2 = L$. Now we expand $\ln Y$ around $\gamma = 0$ (recall the CES approximates to a cobb-douglas production function when $\gamma \approx0).$
$\gamma^0$ term
$$
\lim_{\gamma \to 0} \ln Y = \ln (A K^\alpha L^{1 - \alpha}) \tag{2}
$$
$\gamma^1$ term
\begin{eqnarray}
\lim_{\gamma \to 0} \frac{\partial \ln Y}{\partial \gamma} &=& \lim_{\gamma \to 0}\frac{\alpha K^{\gamma } \ln (L)+(1-\alpha ) l^{\gamma } \log (L)}{\gamma
\left(\alpha K^{\gamma }+(1-\alpha ) L^{\gamma }\right)}-\frac{\ln \left(\alpha
K^{\gamma }+(1-\alpha ) L^{\gamma }\right)}{\gamma ^2}\\
&=& \frac{1}{2} (1 - \alpha) \alpha (\ln (K)-\ln (L))^2 \tag{3}
\end{eqnarray}
Up to first order we have then
\begin{eqnarray}
\ln Y &\approx& \color{blue}{(\ln Y)_{\gamma = 0}} + \color{red}{\left(\frac{\partial \ln Y}{\partial \gamma}\right)_{\gamma = 0} \gamma} \\
&\stackrel{(2),(3)}{=}& \color{blue}{\ln A + \alpha \ln K + (1 - \alpha) \ln L} + \color{red}{\frac{1}{2}\alpha(1 - \alpha)\gamma [\ln K - \ln L]^2} \\
&=& \ln A + \alpha \ln X_1 + (1 - \alpha) \ln X_2 + \frac{\alpha \gamma (1 -\alpha)}{2}\left[\ln^2 X_1 -2\ln X_1\ln X_2 + \ln^2 X_2 \right] \\
&=& \alpha_0 + \sum_{i = 1}^2 \alpha_i \ln X_i + \frac{1}{2}\sum_{i, j = 1}^2 \beta_{ij}\ln X_i \ln X_j \tag{3}
\end{eqnarray}
This is naturally extended to $n > 2$ as
$$
\ln Y = \alpha_0 + \sum_{i = 1}^n \alpha_i \ln X_i + \frac{1}{2}\sum_{i, j = 1}^n \beta_{ij}\ln X_i \ln X_j
$$