Melt the butter in a skillet over medium heat and cook the mushrooms for 7 minutes, until the liquid they release has cooked away.
Add the diced pear and cook for 2 more minutes, then stir in the thyme, salt and pepper, and let the mixture cool for 10 minutes.
Preheat the oven to 400F and line a baking sheet with parchment.
Unfold the pastry on a floured counter and roll it slightly to about 10 by 12 inches.
Spread the cooled mushroom and pear mixture down the center third of the sheet, lengthwise, then scatter the gruyere over it.
Fold the two long sides of the pastry over the filling to overlap slightly in the middle, forming a log, and press the seam to seal.
Turn the log seam side down, brush all over with egg wash, and cut 8 shallow diagonal slashes across the top to let steam escape.
Bake for 22 to 25 minutes, until deep golden and firm, then cool for 10 minutes and slice into 16 pieces with a serrated knife so the layers stay distinct.
Good to Know
Bake the whole log a day ahead, cool completely, then slice and rewarm for 5 minutes before serving so the cut edges stay crisp.