Demonstrates how to delete a Cloud Logging Sink.

## Code sample

### C#


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```c#
private void DeleteSink(string sinkId)
{
    var sinkClient = ConfigServiceV2Client.Create();
    LogSinkName sinkName = new LogSinkName(s_projectId, sinkId);
    sinkClient.DeleteSink(sinkName, _retryAWhile);
    Console.WriteLine($"Deleted {sinkId}.");
}
```

### Go


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```go
import (
	"context"
	"log"

	"cloud.google.com/go/logging/logadmin"
)

func deleteSink(projectID string) error {
	ctx := context.Background()
	client, err := logadmin.NewClient(ctx, projectID)
	if err != nil {
		log.Fatalf("logadmin.NewClient: %v", err)
	}
	defer client.Close()
	if err := client.DeleteSink(ctx, "severe-errors-to-gcs"); err != nil {
		return err
	}
	return nil
}
```

### Java


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```java
boolean deleted = logging.deleteSink(sinkName);
if (deleted) {
  // the sink was deleted
} else {
  // the sink was not found
}
```

### PHP


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```php
use Google\Cloud\Logging\LoggingClient;

/**
 * Delete a log sink.
 *
 * @param string $projectId The Google project ID.
 * @param string $sinkName The name of the sink.
 */
function delete_sink($projectId, $sinkName)
{
    $logging = new LoggingClient(['projectId' => $projectId]);
    $logging->sink($sinkName)->delete();
    printf("Deleted a sink '%s'." . PHP_EOL, $sinkName);
}
```

### Python


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
def delete_sink(sink_name):
    """Deletes a sink."""
    logging_client = logging.Client()
    sink = logging_client.sink(sink_name)

    sink.delete()

    print("Deleted sink {}".format(sink.name))

```

### Ruby


To learn how to install and use the client library for Logging, see
[Logging client libraries](https://docs.cloud.google.com/logging/docs/reference/libraries.md.txt).


To authenticate to Logging, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```ruby
require "google/cloud/logging"

logging = Google::Cloud::Logging.new

# sink_name = "name-of-my-sink"
sink = logging.sink sink_name
sink.delete
puts "Deleted sink: #{sink.name}"
```

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples.md.txt?product=cloudlogging).