Supprimer un récepteur
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Explique comment supprimer un récepteur Cloud Logging.
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[],[],null,["# Delete a sink\n\nDemonstrates how to delete a Cloud Logging Sink.\n\nCode sample\n-----------\n\n### C#\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n private void DeleteSink(string sinkId)\n {\n var sinkClient = ConfigServiceV2Client.Create();\n LogSinkName sinkName = new LogSinkName(s_projectId, sinkId);\n sinkClient.DeleteSink(sinkName, _retryAWhile);\n Console.WriteLine($\"Deleted {sinkId}.\");\n }\n\n### Go\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import (\n \t\"context\"\n \t\"log\"\n\n \t\"cloud.google.com/go/logging/logadmin\"\n )\n\n func deleteSink(projectID string) error {\n \tctx := context.Background()\n \tclient, err := logadmin.https://cloud.google.com/go/docs/reference/cloud.google.com/go/logging/latest/logadmin.html#cloud_google_com_go_logging_logadmin_Client_NewClient(ctx, projectID)\n \tif err != nil {\n \t\tlog.Fatalf(\"logadmin.NewClient: %v\", err)\n \t}\n \tdefer client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/logging/latest/logadmin.html#cloud_google_com_go_logging_logadmin_Client_Close()\n \tif err := client.https://cloud.google.com/go/docs/reference/cloud.google.com/go/logging/latest/logadmin.html#cloud_google_com_go_logging_logadmin_Client_DeleteSink(ctx, \"severe-errors-to-gcs\"); err != nil {\n \t\treturn err\n \t}\n \treturn nil\n }\n\n### Java\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n boolean deleted = logging.deleteSink(sinkName);\n if (deleted) {\n // the sink was deleted\n } else {\n // the sink was not found\n }\n\n### Node.js\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Imports the Google Cloud client library\n const {Logging} = require('https://cloud.google.com/nodejs/docs/reference/logging/latest/overview.html');\n\n // Creates a client\n const logging = new https://cloud.google.com/nodejs/docs/reference/logging/latest/logging/logging.html();\n\n /**\n * TODO(developer): Uncomment the following line to run the code.\n */\n // const sinkName = 'Name of sink to delete, e.g. my-sink';\n\n const sink = logging.sink(sinkName);\n\n async function deleteSink() {\n // See https://googleapis.dev/nodejs/logging/latest/Sink.html#delete\n await sink.delete();\n console.log(`Sink ${sinkName} deleted.`);\n }\n deleteSink();\n\n### PHP\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n use Google\\Cloud\\Logging\\LoggingClient;\n\n /**\n * Delete a log sink.\n *\n * @param string $projectId The Google project ID.\n * @param string $sinkName The name of the sink.\n */\n function delete_sink($projectId, $sinkName)\n {\n $logging = new LoggingClient(['projectId' =\u003e $projectId]);\n $logging-\u003esink($sinkName)-\u003edelete();\n printf(\"Deleted a sink '%s'.\" . PHP_EOL, $sinkName);\n }\n\n### Python\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def delete_sink(sink_name):\n \"\"\"Deletes a sink.\"\"\"\n logging_client = logging.Client()\n sink = logging_client.sink(sink_name)\n\n sink.delete()\n\n print(\"Deleted sink {}\".format(sink.name))\n\n### Ruby\n\n\nTo learn how to install and use the client library for Logging, see\n[Logging client libraries](/logging/docs/reference/libraries).\n\n\nTo authenticate to Logging, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n require \"google/cloud/logging\"\n\n logging = Google::Cloud::https://cloud.google.com/ruby/docs/reference/google-cloud-service_control-v1/latest/Google-Cloud-Logging.html.https://cloud.google.com/ruby/docs/reference/google-cloud-logging/latest/Google-Cloud-Logging.html\n\n # sink_name = \"name-of-my-sink\"\n sink = logging.sink sink_name\n sink.delete\n puts \"Deleted sink: #{sink.name}\"\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=logging)."]]