I think you can use the SPWebConfigModification without stsadm requirement.
here is the example:
Lets say you want to change mode value to Off.
<configuration>
<system.web>
<customErrors mode="On">
<system.web>
<configuration>
here is the code
private void SimpleSample()
{
// Get an instance of my local web application
SPWebApplication webApp = new SPSite("http://localhost").WebApplication;
// Create my new modification to set the mode attibute to "Off".
// Example: <customErrors mode="Off">
SPWebConfigModification modification = new SPWebConfigModification("mode", "system.web/customErrors");
modification.Owner = "SimpleSampleUniqueOwnerValue";
modification.Sequence = 0;
modification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute;
modification.Value = "Off";
// Add my new web.config modification.
webApp.WebConfigModifications.Add(modification);
// Save web.config changes.
webApp.Update();
// Applies the list of web.config modifications to all Web applications in this Web service across the farm.
webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications
}
read more over here: How To: Modify the web.config file in SharePoint using SPWebConfigModification
Managing Web.config Modifications