There is a web.config file under the _layouts folder. This is worth being aware of as you may notice that files that you access from the _layouts folder may not behave as you would expect. This came to my attention when I was getting the following error:
”To enable the details of this specific error message to be viewable on remote machines, please create a
This initially surprised me as I knew that I had already done as such and had recently seen the default error screens when I was building web parts on content pages.
As the web.config under the layouts folder is deeper in the site hierarchy, any elements defined here will overwrite those defined at the web application level. By default the customErrors element exists at this level and it must be set accordingly to your needs as well.
As always, be careful when editing web.config files and always make a backup beforehand.