If we can safely assume that any line with at least two - starts with a date, you could simply useUse -T as the field separator and take the 1st field as the name of the file to split by year:
awk -F- '($3){d=$1}{print > d".log"}' logfile
And to split by month:
awk -F- '($3){d=$1$2}{print > d".log"}' logfile
The trick here is to see if there is a third field (so, at least two -) and then save either the 1st field (the year, $1) or the 1st and 2nd fields (year and month, $1$2) as ddelimiter and use that variable as the name of the file.
If your data is not clean enough to allow that approach, you can check for date-like strings explicitly. For example, to split by year:
awk -FT '($1~/^[0-9]+-[0-9]+-[0-9]+$/){d=substr($1,1,4)}{print > d".log"}' logfile
And by year+month:
awk -FT '($1~/^[0-9]+-[0-9]+-[0-9]+$/){split($1,d,"-")}{print > d[1]d[2]".log"}' logfile
Here, we check that the first field (defined by whitespace nowT, so the whole date on lines starting with dates, that's what -FT means) is a set of 3 numbers separated by -. If it is, to get the year, we extract the first 4 characters (d=substr($1,1,4)) and, to get the month, we split the 1st field on -, saving the resulting strings in the array d (split($1,d,"-")), and use the 1st two elements of the array (d[1]d[2]) for the file name.