Does entropy decrease through measurement? For an electron in its rest frame, we have an entropy 
$$
S = \log 2,
$$
which comes from the 2 possible spin directions along z-axis. 
If the measurement $S_z$ changes its state to $\left| + \right>$, the entropy goes to zero.
Does this violate the second law of thermodynamics?
 A: The entropy of the measured system decreases, at the expense of the entropy of the detector, which goes up. The total entropy balance is positive (as irreversibly fixing detection results usually costs more entropy than is gained from the reduction in the measured system.
Thus the second law is not violated.
Edit: About deriving such results: In a fully microscopic description the entropy remains constant, but nothing can be measured as there is no microscopic concept of a permanent record of measurement results. One, therefore, needs appropriate coarse-graining assumptions, which take the place of Boltzmann's 19th century Stosszahl ansatz for classical molecular systems.
Coarse graining means that the density matrix is restricted to take a form depending only on macroscopically measurable parameters, and deviations from this form (due to the exact dynamics) are swept under the coarse-graining carpet. This leads to approximate macroscopic dynamics. The resulting description is dissipative in the Markovian limit: The entropy $Tr(-\rho\log\rho)$ strictly increases with time unless the system is already in equilibrium.
A book covering this nicely and in full detail for a number of coarse-graining recipes is Grabert's ''Projection operator techniques in nonequilibrium statistical mechanics''. For a readable summary of the basic technique, see, e.g., https://arxiv.org/abs/cond-mat/9612129.
A: tl;dr: You decrease the system's entropy but increase it in the measuring device.
Quoting parts of my own answer to Entropy-based refutation of Shalizi's Bayesian backward arrow of time paradox? at CrossValidated:

As it was pointed out in comments, what matters to thermodynamics, is the entropy of a closed system. That is, according to the second law of thermodynamics, entropy of a closed system cannot decrease. It says nothing about the entropy of a subsystem (or an open system); otherwise you couldn't use your fridge.
And once we measure sth (i.e. interact and gather information) it is not a closed system anymore. Either we cannot use the second law, or - we need to consider a closed system made of the measured system and the observer (i.e. ourselves).
In particular, when we measure the exact state of a particle (while before we knew its distribution), indeed we lower its entropy. However, to store the information we need to increase our entropy by at least the same amount (typically there is huge overhead).
[...]
To be consistent with classical mechanics (and quantum as well), you cannot make a function arbitrarily mapping anything to all zeros (with no side effects). You can make a function mapping your memory to all zero, but at the same time dumping the information somewhere, which effectively increases the entropy of the environment.
(The above originates from Hamiltonian dynamics - i.e. preservation of the phase space in the classical case, and unitarity of evolution in the quantum case.)
PS: A trick for today - "reducing entropy":

*

*Flip an unbiased coin, but don't look at the result (H=1 bit).

*Open your eyes. Now you know its state, so its entropy is H=0 bits.


A: The well-tested second law of thermodynamics is not violated, because the second law is a statement about the production of entropy $\Delta_i S \geq 0$. For an isolated system $\Delta S = \Delta_i S$ and entropy does not decrease $\Delta S \geq 0$, but for open or closed systems $\Delta S = (\Delta_i S + \Delta_e S) \geq \Delta_e S$ and entropy can increase decrease or remain constant in function of the flow term $\Delta_e S$. For instance for mature living systems entropy remains approx. constant because the flow term compensates the production of entropy $\Delta_e S = - \Delta_i S$.
Regarding quantum systems, generalized measurements can decrease the entropy of the system, but non-selective ideal measurements never decrease the entropy. Both cases are compatible with the second law of thermodynamics.
A: A more universal formula for entropy valid under a wide range of conditions is $$S = - k_B \sum_i p_i \ln p_i$$   In this case we have an electron that can be in one of two degenerate states if there is no electrical or magnetic field present.  The two states are spin +1/2 and spin -1/2.  A given electron will be in one of those states with equal probability and there are two states, so $p_1 = 1/2$ and $p_2 = 1/2$.
Plugging these into the formula above we get $S = k_B \ln 2$ where $k_B$ is Boltzmann's constant (left out of the equation in the question).
Since we don't know what state the electron is in, flipping it to the other state does nothing to the entropy.  So we must separate the states by, say, the application of a magnetic field.  One state will now have more energy and the other less.  If we find the electron in the upper energy state, $p_1 = 0$ and $p_2 = 1$.  Evaluating the formula is a bit tricky because we have a term $0\ln 0$ which can be shown to evaluate to zero.  The term $1\ln 1$ also evaluates to zero so we now have $S = 0$ and the entropy has been reduced.
Does this violate the Second Law?  The answer is no primarily because you can't apply thermodynamics to a single particle.
I apologize for the skeletal answer here, but the subject is fairly complex and one would need to read the appropriate chapter(s) in a statistical thermodynamics book for a full discussion.
