Filmic Log: How to render a texture to appear identical to the input image?
Images look correct only if they are displayed on the color space that they were encoded to use, or if the color transform to the display deals with the conversion to a different display or color space.
If your image is not log encoded you should never set it to use log as color space. I presume the image is encoded as sRGB sot that is the only color space you can set it as. The issue is that log and filmic use a much larger dynamic range, while the jpeg you are importing is limited to display referred values. Start by reading the post on this site on filmic
Render with a wider dynamic range in cycles to produce photorealistic looking images
and
How to mix a jpeg background image with a 3D scene generated using Filmic Blender?
By reading that you will realize that there is no perfect way to mix apples and oranges, other than using images that are using scene referred values (log encoded or linear EXRs). Images encoded as sRGB are impossible to reverse to linear scene referred values, they can only be linearized to display referred linear (form 0 to 1).
The problem lies in how display referred images are encoded, besides reversing the gamma curve (trivial issue), the way the highlights and shadows are encoded is already non-linear, as it is something that each individual camera does differentrly, and therefore not reversible to linear values accurately. You can play with curves and even with the ASC-CDL node to try to modify the values, but know that at that point is all hokus-pokus and unscientific as it gets, plus you will quickly run into issues where banding and other quantization errors will appear, particularly in 8bit images. Moreover, jpeg is a terrible format to begin with, and will also break once you start distorting the values that make such compression scheme work, showing macroblocks and fuzzy edges.
Display referred image created on a camera is already taking into consideration the fact that we perceive light in a non linear way, as we see better into the shadows than in the highlights, so those images are created to emulate that and therefore need to skew the way values for shadows and highlights are assigned. There are more bits used for the shadows. If you try to linearize the information you will find that at lot of the information on the highlights is just not there, and any tool will have a hard time inventing what is not there.