The invention discloses an all-optical logic gate based on a non-linear phase shift fiber bragg grating. A signal source is arranged and is connected with a first wavelength division multiplexer port I, a first wavelength division multiplexer port II is connected with a second optical isolator port I, a second optical isolator port II is connected with a third band-pass filter port I, a third band-pass filter port II is connected with a second non-linear phase shift fiber bragg grating input port I through a second optical circulator, an output port of the second non-linear phase shift fiber bragg grating is connected with a fourth band-pass filter port I, and a fourth band-filter port II is connected with a second wavelength division multiplexer; a first optical isolator is connected with a first band-pass filter port I, a first band-pass filter port II is connected with an input port I of a first non-linear phase shift fiber bragg grating through a first optical circulator, an output port of a first non-linear phase shift fiber bragg grating is connected with a second band-pass filter port I, and a second band-pass filter port II is connected with a third wavelength division multiplexer.