The optimality criterion used by logistic regression (and many other methods) is the likelihood function. It is used to estimate $\beta$ including multiple $\beta$ representing one $X$ to achieve quadratic, cubic, and piecewise polynomial (spline) fits. It can also be used to choose from among competing transformations of $X$ but the act of choosing will not be reflected in the information matrix, so the resulting variance of $X\hat{\beta}$ will be too small, making confidence intervals not have the stated coverage probability. If you make transformation estimation an explicit goal of model fitting (and regression splines are excellent ways to do this) you will preserve all aspects of statistical inference. Depending on the sample size, a restricted (linear in both tails) cubic spline with 4 knots, requiring 3 parameters, can be a good choice.