There are many difficulties with overlapping areas in the Vim syntax highlighting simulator. The order in which matches and regions are defined matters, and it can be very difficult to get it to do what you want.
The main thing I suggest is to look :help syn-pattern-offset . This makes it possible to make a region at the beginning of the template, by the way. For example, if your end pattern is:
end=/pattern/re=s-1
Then the area will end with a character before p pattern.
It takes a lot of effort to get it working, and I'm far from being an expert in this, but to get you started, try the following:
syntax match logDate /^\d\{4}-\d\{2}-\d\{2}/ containedin=logDateTimeTypeLine nextgroup=logTime skipwhite syntax match logTime /\d\{2}:\d\{2}:\d\{2},\d\{3}/ containedin=logDateTimeTypeLine,logTrace syntax match logDateTimeTypeLine /^\d\{4}-\d\{2}-\d\{2} \d\{2}:\d\{2}:\d\{2},\d\{3}.*/ syntax region logTrace matchgroup=logErrorStartLine start=/^\d\{4}-\d\{2}-\d\{2} \d\{2}:\d\{2}:\d\{2},\d\{3}.*ERROR.*/ms=s,rs=e+1 end=/^\d\{4}-\d\{2}-\d\{2} \d\{2}:\d\{2}:\d\{2},\d\{3}/me=s-1,he=s-1,re=s-1 hi link logTrace Error hi link logDateTimeTypeLine Keyword hi link logDate String hi link logTime Comment hi logErrorStartLine guifg=red
source share