Skip to content

Commit

Permalink
Updated docs for logs (#1586)
Browse files Browse the repository at this point in the history
* Updated docs for logs

* Remove extra space

* Corrected the propertyname to TargetFrameworks

* Updated TargetFrameworks property

* Addressed PR comments

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
  • Loading branch information
utpilla and cijothomas authored Nov 23, 2020
1 parent daa83ca commit 0abe85d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/logs/extending-the-sdk/extending-the-sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>net461;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
75 changes: 73 additions & 2 deletions docs/logs/getting-started/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,74 @@
# Getting Started with OpenTelemetry .NET in 5 Minutes
# Getting Started with OpenTelemetry .NET Logs in 5 Minutes

TBD
First, download and install the [.NET Core
SDK](https://dotnet.microsoft.com/download) on your computer.

Create a new console application and run it:

```sh
dotnet new console --output getting-started
cd getting-started
dotnet run
```

You should see the following output:

```text
Hello World!
```

Let's install the packages to get started with logging. If your ConsoleApp
targets `netcoreapp2.1` install the version `2.1.1` of
`Microsoft.Extensions.Logging` and `Microsoft.Extensions.DependencyInjection`
packages:

```sh
dotnet add package Microsoft.Extensions.Logging -v 2.1.1
```

```sh
dotnet add package Microsoft.Extensions.DependencyInjection -v 2.1.1
```

If your ConsoleApp targets a framework other than `netcoreapp2.1`, install the
latest Microsoft.Extensions.Logging package:

```sh
dotnet add package Microsoft.Extensions.Logging
```

Install the
[OpenTelemetry.Exporter.Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
package (Use the latest version):

```sh
dotnet add package OpenTelemetry.Exporter.Console -v 1.0.0-rc1.1
```

Update the `Program.cs` file with the code from [Program.cs](./Program.cs):

Run the application again (using `dotnet run`) and you should see the log output
on the console.

```text
LogRecord.TraceId: 00000000000000000000000000000000
LogRecord.SpanId: 0000000000000000
LogRecord.Timestamp: 2020-11-13T23:50:33.5764463Z
LogRecord.EventId: 0
LogRecord.CategoryName: Program
LogRecord.LogLevel: Information
LogRecord.TraceFlags: None
LogRecord.State: Hello from tomato 2.99.
```

Congratulations! You are now collecting logs using OpenTelemetry.

What does the above program do?

The program uses the
[`ILogger`](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger)
API to log a formatted string with a severity level of Information. Click
[here](https://docs.microsoft.com/dotnet/api/microsoft.extensions.logging.loglevel)
for more information on the different logs levels. Opentelemetry captures this
and sends it to `ConsoleExporter`. `ConsoleExporter` simply displays it on the
console.
4 changes: 4 additions & 0 deletions docs/logs/getting-started/getting-started.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.Exporter.Console\OpenTelemetry.Exporter.Console.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion docs/trace/getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Install the
package:

```sh
dotnet add package OpenTelemetry.Exporter.Console -v 0.7.0-beta.1
dotnet add package OpenTelemetry.Exporter.Console -v 1.0.0-rc1.1
```

Update the `Program.cs` file with the code from [Program.cs](./Program.cs):
Expand Down

0 comments on commit 0abe85d

Please sign in to comment.