// Sample: RegisterExceptionLogger
        public static void Register(HttpConfiguration config)
        {
            string projectId   = "[Google Cloud Platform project ID]";
            string serviceName = "[Name of service]";
            string version     = "[Version of service]";

            // Add a catch all for the uncaught exceptions.
            config.Services.Add(typeof(IExceptionLogger),
                                CloudErrorReportingExceptionLogger.Create(projectId, serviceName, version));
        }
Example #2
0
        // [START register_error_reporting]
        public static void Register(HttpConfiguration config)
        {
            string projectId   = "YOUR-PROJECT-ID";
            string serviceName = "NAME-OF-YOUR-SERVICE";
            string version     = "VERSION-OF-YOUR-SERVCICE";

            // [START _EXCLUDE]
            // Check to ensure that projectId has been changed from placeholder value.
            if (projectId == ("YOUR-PROJECT" + "-ID"))
            {
                throw new Exception("Set string projectId above to be your project id.");
            }
            // [END _EXCLUDE]
            // Add a catch all for the uncaught exceptions.
            config.Services.Add(typeof(IExceptionLogger),
                                CloudErrorReportingExceptionLogger.Create(projectId, serviceName, version));
            // [START _EXCLUDE]
            var emptyDictionary = new HttpRouteValueDictionary();

            // Add our one HttpMessageHandler to the root path.
            config.Routes.MapHttpRoute("index", "", emptyDictionary, emptyDictionary,
                                       new HelloWorldHandler());
            // [END _EXCLUDE]
        }
Example #3
0
 private CloudErrorReportingExceptionLogger GetLogger(ReportErrorsServiceClient client)
 {
     return(CloudErrorReportingExceptionLogger.Create(client, ProjectId, ServiceName, Version));
 }