@@ -22,45 +22,53 @@ See below for examples on how to configure Honeybadger for different types of ap
22
22
23
23
### For .Net Core Web App
24
24
25
- 1 . Install Honeybadger.DotNetCore from Nuget
26
- ```
27
- dotnet add package Honeybadger.DotNetCore
28
- ```
29
- 2 . Register the _ Honeybadger Middleware_ :
30
- ``` c#
31
- var builder = WebApplication .CreateBuilder (args );
32
- builder .AddHoneybadger (new HoneybadgerOptions (" apiKey" ));
33
- ```
34
-
35
- Or you can configure Honeybadger through your ` appsettings.json ` file, by adding a ` Honeybadger ` section:
36
- ``` json
37
- {
38
- "Honeybadger" : {
39
- "ApiKey" : " apiKey" ,
40
- "AppEnvironment" : " Development" ,
41
- "ReportData" : true
42
- }
25
+ #### 1. Install Honeybadger.DotNetCore from Nuget
26
+
27
+ ``` sh
28
+ dotnet add package Honeybadger.DotNetCore
29
+ ```
30
+
31
+ #### 2. Register the _ Honeybadger Middleware_ :
32
+
33
+ ``` c#
34
+ var builder = WebApplication .CreateBuilder (args );
35
+ builder .AddHoneybadger (new HoneybadgerOptions (" apiKey" ));
36
+ ```
37
+
38
+ Or you can configure Honeybadger through your ` appsettings.json ` file, by adding a ` Honeybadger ` section:
39
+
40
+ ``` json
41
+ {
42
+ "Honeybadger" : {
43
+ "ApiKey" : " apiKey" ,
44
+ "AppEnvironment" : " Development" ,
45
+ "ReportData" : true
43
46
}
44
- ```
45
- And simply call ` AddHoneybadger ` without any parameters:
46
- ``` c#
47
- var builder = WebApplication .CreateBuilder (args );
48
- builder .AddHoneybadger ();
49
- ```
47
+ }
48
+ ```
49
+
50
+ And simply call ` AddHoneybadger ` without any parameters:
51
+
52
+ ``` c#
53
+ var builder = WebApplication .CreateBuilder (args );
54
+ builder .AddHoneybadger ();
55
+ ```
50
56
51
57
#### Usage
52
58
53
59
You can access the _ Honeybadger Client_ using _ DI_ :
60
+
54
61
``` c#
55
62
app .MapGet (" /" , ([FromServices ] IHoneybadgerClient client ) =>
56
63
{
57
64
client .AddBreadcrumb (" reached index route" , " route" , new Dictionary <string , object ?>());
58
-
65
+
59
66
return " Hello World!" ;
60
67
});
61
68
```
62
69
63
70
Any unhandled exceptions should be reported to Honeybadger automatically (unless ` ReportUnhandledExceptions ` is set to false):
71
+
64
72
``` c#
65
73
app .MapGet (" /debug" , () =>
66
74
{
@@ -70,83 +78,97 @@ app.MapGet("/debug", () =>
70
78
71
79
See example project in ` examples/Honeybadger.DotNetCoreWebApp ` .
72
80
73
- ### As a custom logging provider
74
-
75
- 1 . Install Honeybadger.Extensions.Logging from Nuget
76
- ```
77
- dotnet add package Honeybadger.Extensions.Logging
78
- ```
79
- 2 . Register Honeybadger and additionally the custom logging provider:
80
- ``` c#
81
- var builder = WebApplication .CreateBuilder (args );
82
- // or set the configuration in the appsettings.json file
83
- builder .AddHoneybadger (new HoneybadgerOptions (" apiKey" ));
84
- builder .Logging .AddHoneybadger ();
85
- ```
86
-
87
- You should also configure the minimum log level as you would configure other log providers in .Net Core.
88
- The following would report only logged errors:
89
- ``` json
90
- {
91
- "Logging" : {
92
- "Honeybadger" : {
93
- "Default" : " Error"
94
- }
95
- }
81
+ ### As a custom logging provider
82
+
83
+ #### 1. Install Honeybadger.Extensions.Logging from Nuget
84
+
85
+ ``` sh
86
+ dotnet add package Honeybadger.Extensions.Logging
87
+ ```
88
+
89
+ #### 2. Register Honeybadger and additionally the custom logging provider:
90
+
91
+ ``` c#
92
+ var builder = WebApplication .CreateBuilder (args );
93
+ // or set the configuration in the appsettings.json file
94
+ builder .AddHoneybadger (new HoneybadgerOptions (" apiKey" ));
95
+ builder .Logging .AddHoneybadger ();
96
+ ```
97
+
98
+ You should also configure the minimum log level as you would configure other log providers in .Net Core.
99
+ The following would report only logged errors:
100
+
101
+ ``` json
102
+ {
103
+ "Logging" : {
104
+ "Honeybadger" : {
105
+ "Default" : " Error"
106
+ }
96
107
}
97
- ```
98
- And simply call ` AddHoneybadger ` and ` Logging.AddHoneybadger ` without any parameters:
99
- ``` c#
100
- var builder = WebApplication .CreateBuilder (args );
101
- builder .AddHoneybadger ();
102
- builder .Logging .AddHoneybadger ();
103
- ```
104
- Note: If you want to disable automatic reporting of unhandled exceptions, you can set the ` ReportUnhandledExceptions ` property to ` false ` in the ` HoneybadgerOptions ` :
105
- ``` json
106
- {
107
- "Honeybadger" : {
108
- "ApiKey" : " apiKey" ,
109
- "AppEnvironment" : " Development" ,
110
- "ReportData" : true ,
111
- "ReportUnhandledExceptions" : false
112
- }
108
+ }
109
+ ```
110
+
111
+ And simply call ` AddHoneybadger ` and ` Logging.AddHoneybadger ` without any parameters:
112
+
113
+ ``` c#
114
+ var builder = WebApplication .CreateBuilder (args );
115
+ builder .AddHoneybadger ();
116
+ builder .Logging .AddHoneybadger ();
117
+ ```
118
+
119
+ Note: If you want to disable automatic reporting of unhandled exceptions, you can set the ` ReportUnhandledExceptions ` property to ` false ` in the ` HoneybadgerOptions ` :
120
+
121
+ ``` json
122
+ {
123
+ "Honeybadger" : {
124
+ "ApiKey" : " apiKey" ,
125
+ "AppEnvironment" : " Development" ,
126
+ "ReportData" : true ,
127
+ "ReportUnhandledExceptions" : false
113
128
}
114
- ```
129
+ }
130
+ ```
115
131
116
132
#### Usage
117
133
118
134
Errors from the ` logger ` will be reported to Honeybadger:
119
- ``` c#
120
- app .MapGet (" /notify" , ([FromServices ] ILogger logger ) =>
121
- {
122
- logger .LogError (" hello from Honeybadger.Logger!" );
123
-
124
- return " Log reported to Honeybadger. Check your dashboard!" ;
125
- });
126
- ```
135
+
136
+ ``` c#
137
+ app .MapGet (" /notify" , ([FromServices ] ILogger logger ) =>
138
+ {
139
+ logger .LogError (" hello from Honeybadger.Logger!" );
140
+
141
+ return " Log reported to Honeybadger. Check your dashboard!" ;
142
+ });
143
+ ```
127
144
128
145
See example project in ` examples/Honeybadger.DotNetCoreWebApp.Logger ` .
129
146
130
147
### Using the SDK manually
131
148
132
- 1 . Install the [ Honeybadger Nuget] ( https://www.nuget.org/packages/Honeybadger ) .
133
- ```
134
- dotnet add package Honeybadger
135
- ```
136
- 2 . Initialize the _ Honeybadger Client_ :
137
- ``` c#
138
- using Microsoft .Extensions .Options ;
139
-
140
- var options = new HoneybadgerOptions (" apiKey" );
141
- var client = new HoneybadgerClient (Options .Create (options ));
142
- ```
143
- 3 . Call ` notify ` to report to Honeybadger:
144
- ``` c#
145
- // blocking
146
- client .Notify (" hello from .Net !" );
147
- // or async
148
- await client .NotifyAsync (" hello from .Net !" );
149
- ```
149
+ #### 1. Install the [ Honeybadger Nuget] ( https://www.nuget.org/packages/Honeybadger ) .
150
+
151
+ ``` sh
152
+ dotnet add package Honeybadger
153
+ ```
154
+
155
+ #### 2. Initialize the _ Honeybadger Client_ :
156
+
157
+ ``` c#
158
+ using Microsoft .Extensions .Options ;
159
+
160
+ var options = new HoneybadgerOptions (" apiKey" );
161
+ var client = new HoneybadgerClient (Options .Create (options ));
162
+ ```
163
+
164
+ #### 3. Call ` notify ` to report to Honeybadger:
165
+
166
+ ``` c#
167
+ // blocking
168
+ client .Notify (" hello from .Net !" );
169
+ // or async
170
+ await client .NotifyAsync (" hello from .Net !" );
171
+ ```
150
172
151
173
See example project in ` examples/Honeybadger.Console ` .
152
174
@@ -171,6 +193,7 @@ Conventional Commits are enforced with a pre-commit git hook (using [husky](http
171
193
172
194
All packages are published on nuget.org with a [ Github Actions Worfklow] ( ./.github/workflows/release.yml ) .
173
195
The workflow does the following:
196
+
174
197
- ` dotnet versionize ` - bump versions and generate changelog
175
198
- ` dotnet pack `
176
199
- ` dotnet package push `
@@ -179,11 +202,12 @@ _Note: only users with write permissions can trigger this workflow (i.e. Collabo
179
202
180
203
### Manual Releases
181
204
182
- Our automated release process is not yet fully functional for the following reason:
183
- Since ` Honeybadger ` is a dependency of ` Honeybadger.Extensions.Logging ` and ` Honeybadger.DotNetCore ` ,
205
+ Our automated release process is not yet fully functional for the following reason:
206
+ Since ` Honeybadger ` is a dependency of ` Honeybadger.Extensions.Logging ` and ` Honeybadger.DotNetCore ` ,
184
207
we need to release ` Honeybadger ` first, then update the dependencies in the other projects and finally release those two projects.
185
208
186
209
To release manually, execute the following steps:
210
+
187
211
1 . Run ` dotnet versionize ` in the root directory. This will bump the version in all projects and commit the new version as a tag.
188
212
2 . Run ` dotnet pack ./src/Honeybadger --configuration Release `
189
213
3 . Run ` dotnet nuget push ./src/Honeybadger/bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json --api-key YOUR_API_KEY `
0 commit comments