The Logrank test is a nonparametric hypothesis test that is used to compare the survival distribution of samples.
This test is also known as the Mantel Cox test and is used when the survival curves do not cross each other (proportionality assumption). Also the data are right skewed and censored. To determine whether or not differences exist in the survival experiences of two groups, for e.g. patients in treatment groups in a clinical trial, a log rank test can be used. A Chisquare test by comparing the proportions of surviving worked out beyond an arbitrarily chosen time would not work here as it would be difficult to define efficient and unbiased proportions due to the presence of censoring. Also choice of time to perform the test would be arbitrary and can result in incorrect comparison of the distribution curves at a single time. However the 2X2 table used in the chisquare test can be used. The logrank test tests the null hypothesis that is that the survival distributions of the two groups are same. Now if the null hypothesis is accepted, then numbers failing in the 2X2 table will be in ratio of the numbers at risk in the groups. The expected number of failures calculated in each group can be added across all the time. These values are compared with actual numbers of failures in the two groups in the logrank test. For example: for the 2X2 table as shown

Failed 
Surviving 
At risk 
Group A 
d_{A} 
n_{A} d_{A} 
n_{A} 
Group B 
d_{A} 
n_{B} d_{B} 
n_{B} 
Combined 
d 
nd 
n 
If null hypothesis is true then, it is expected that the total number of failures (d) is distributed between the groups proportionally according to the group sizes. So expected number of failures in group A at this time = EAt = d × nA/n. Now the table at next failure time is calculated in way similar to updating of table used in the calculation of the KaplanMeier estimate, using this table at a given failure time. Each group is updated separately and number at risk in next table is the number at risk in present table minus the number failing in the present table minus the number of individuals censored between the present table. The log rank statistic is calculated after the tables for each failure time has been found and the pvalue is found by y referring this to a χ2 distribution with 1 degree of freedom