In this paper, we are going to propose a novel structure of all-optical NOT, XOR and XNOR logic gates are presented using a two-dimensional photonic crystal (2D-PhC). This structure is optimized by varying the radius of the cavity, to obtain a quality factor Q = 1192, and also has several ports of entry and one port of output. The size of each structure is equal to 85.8 μm2. The contrast ratios for the structures proposed all-optical NOT, XOR and XNOR logic gates between levels “0” and “1” are, respectively, 25.08, 25.03, and 14.47 dB. The response time for the three logical gates is 8.33 ps, and the bit rate is calculated at about 0.12 Tbit/s, all simulations are based on both numerical methods such as finite difference time domain (FDTD) and plane wave expansion (PWE). Designed logic gates are characterized by low power consumption, compactness and easy integration.