1. Method of detecting in an earth formation a boundary between a first formation region having a known resistivity and a second formation region having a different resistivity, wherein the first formation region is traversed by a wellbore filled with a fluid of known resistivity, using a logging tool provided with a number of electrodes including a monitoring electrode, which method comprises the steps of: a) selecting a location of the logging tool in the wellbore; b) assuming a position of the boundary relative to the selected location of the logging tool, selecting outside the wellbore one or more target points relative to the selected location, and selecting a target value for a selected parameter in each target point; c) assuming a model wherein the logging tool in the wellbore is surrounded by an infinite and homogeneous formation having a resistivity which is equal to the known resistivity of the first formation region, and determining how at least two of the electrodes have to be energized in order that in each of the target points the selected parameter has the target value; d) selecting a monitoring parameter at the monitoring electrode; e) placing the logging tool at the selected location in the wellbore; f) determining at the selected location a detection value of the monitoring parameter resulting from energizing the at least two electrodes as determined in step c); and g) interpreting the detection value of the monitoring parameter in order to detect the boundary.