刪除記錄檔
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
刪除全域 `_Default` 記錄檔值區中記錄檔的所有記錄項目。
程式碼範例
C#
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Go
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Java
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
PHP
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Python
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Ruby
如要瞭解如何安裝及使用 Logging 的用戶端程式庫,請參閱這篇文章。
如要向 Logging 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[],[],null,["# Delete a log\n\nDeletes all the log entries in a log for the global \\`_Default\\` log bucket.\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 DeleteLog(string logId)\n {\n var client = LoggingServiceV2Client.Create();\n LogName logName = new LogName(s_projectId, logId);\n client.DeleteLog(logName, _retryAWhile);\n Console.WriteLine($\"Deleted {logId}.\");\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 deleteLog(projectID string) error {\n \tctx := context.Background()\n \tadminClient, 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(\"Failed to create logadmin client: %v\", err)\n \t}\n \tdefer adminClient.https://cloud.google.com/go/docs/reference/cloud.google.com/go/logging/latest/logadmin.html#cloud_google_com_go_logging_logadmin_Client_Close()\n\n \tconst name = \"log-example\"\n \tif err := adminClient.https://cloud.google.com/go/docs/reference/cloud.google.com/go/logging/latest/logadmin.html#cloud_google_com_go_logging_logadmin_Client_DeleteLog(ctx, name); 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.deleteLog(logName);\n if (deleted) {\n // the log was deleted\n } else {\n // the log 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 logName = 'Name of the log to delete, e.g. my-log';\n\n const log = logging.log(logName);\n\n async function deleteLog() {\n // Deletes a logger and all its entries.\n // Note that a deletion can take several minutes to take effect.\n // See https://googleapis.dev/nodejs/logging/latest/Log.html#delete\n await log.delete();\n console.log(`Deleted log: ${logName}`);\n }\n deleteLog();\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 /** Delete a logger and all its entries.\n *\n * @param string $projectId The Google project ID.\n * @param string $loggerName The name of the logger.\n */\n function delete_logger($projectId, $loggerName)\n {\n $logging = new LoggingClient(['projectId' =\u003e $projectId]);\n $logger = $logging-\u003elogger($loggerName);\n $logger-\u003edelete();\n printf(\"Deleted a logger '%s'.\" . PHP_EOL, $loggerName);\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_logger(logger_name):\n \"\"\"Deletes a logger and all its entries.\n\n Note that a deletion can take several minutes to take effect.\n \"\"\"\n logging_client = logging.Client()\n logger = logging_client.logger(logger_name)\n\n logger.delete()\n\n print(\"Deleted all logging entries for {}\".format(logger.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 # log_name = \"The name of the log\"\n logging.delete_log log_name\n puts \"Deleted log: #{log_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)."]]