Setting up on App Engine Flexible Environment

Stackdriver Error Reporting is automatically enabled for App Engine flexible environment applications. No additional setup is required. Messages written from App Engine to stderr are analyzed and, if found to contain errors, will be displayed by Error Reporting.

See Viewing Errors for instructions on viewing error and exception data for your application in the GCP Console.

Examples using the instrumentation libraries

If you'd like to customize the error information being sent to Error Reporting, you can use the instrumentation libraries available for a number of languages.


Refer to the README for Stackdriver and App Engine Flexible Environment for instructions on running and deploying the Stackdriver sample application.

Google.Cloud.Diagnostics.AspNetCore is a .NET Core client library that enables error reporting for your application using the Logging API v2 and optionally the Error Reporting API v1beta1.

To use the Google.Cloud.Diagnostics.AspNetCore client library:

Right-click your solution in Visual Studio and select Manage Nuget packages for solution.

  1. Select the Include prerelease checkbox.

  2. Search for and install the package named Google.Cloud.Diagnostics.AspNetCore.

  3. Once the Google.Cloud.Diagnostics.AspNetCore client is installed, add the following using directive to your application's source code files when you want to customize the error information being sent to Error Reporting.

     using Google.Cloud.Diagnostics.AspNetCore;

Then complete the following 3 steps to log custom error reports from your application:

  1. Add the following code to your web application's appsettings.json file and update YOUR-GOOGLE-PROJECT-ID to be your project ID or number. Also update NAME-OF-YOUR-SERVICE and VERSION-OF-YOUR-SERVICE to appropriate values for your application:

      "Stackdriver": {
        "ProjectId": "YOUR-GOOGLE-PROJECT-ID",
        "ServiceName": "NAME-OF-YOUR-SERVICE",
        "Version": "VERSION-OF-YOUR-SERVICE"

  2. Create or edit the ConfigureServices method in your application's Startup.cs file and call services.AddGoogleExceptionLogging():

            public void ConfigureServices(IServiceCollection services)
                services.AddGoogleExceptionLogging(options =>
                    options.ProjectId = Configuration["Stackdriver:ProjectId"];
                    options.ServiceName = Configuration["Stackdriver:ServiceName"];
                    options.Version = Configuration["Stackdriver:Version"];
                // Add trace service.
                services.AddGoogleTrace(options =>
                    options.ProjectId = Configuration["Stackdriver:ProjectId"];
                    options.Options = TraceOptions.Create(
                        bufferOptions: BufferOptions.NoBuffer());
                // Add framework services.

  3. Edit the Configure method in your application's Startup.cs file and call app.UseGoogleExceptionLogging() before calling app.UseStaticFiles() and app.UseMvc().

            public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
                // Configure logging service.
                var logger = loggerFactory.CreateLogger("testStackdriverLogging");
                // Write the log entry.
                logger.LogInformation("Stackdriver sample started. This is a log message.");
                // Configure error reporting service.
                // Configure trace service.
                app.UseMvc(routes =>
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");

Now you can send customized error messages as shown in the following example:

throw new Exception("Generic exception for testing Stackdriver Error Reporting");


See Setting Up Stackdriver Error Reporting for Go.


See Setting Up Stackdriver Error Reporting for Java.


See Setting Up Stackdriver Error Reporting for Node.js.


See Setting Up Stackdriver Error Reporting for PHP.


See Setting Up Stackdriver Error Reporting for Python.


See Setting Up Stackdriver Error Reporting for Ruby.

Was this page helpful? Let us know how we did:

Send feedback about...

Stackdriver Error Reporting