You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, no matter what is your option you always must delivery a *SplunkLoggerConfiguration*that can be provided by two ways:
46
+
As you can see, no matter what is your option you always must delivery a *SplunkLoggerConfiguration*when adding a ILogger to the logger factory. You can provide it via config or as hard code:
47
47
48
48
#### Get Configuration From Json File
49
49
50
-
First, and most beautiful one.
50
+
You can provide the configuration from json file using .Net Core 2 configuration binding feature.
51
51
52
-
You can provide the configuration from json file. In this case I will be using *appsettings.json*as source and loading it using .Net Core 2 configuration binding feature.
52
+
For instance at [SampleWebAPI project](https://github.com/vtex/SplunkLogger/tree/master/src/SampleWebAPI) we use the *appsettings.json*file.
53
53
54
-
So first, let's check the json file.
55
54
```json
56
55
{
57
56
"Logging": {
@@ -81,9 +80,9 @@ So first, let's check the json file.
81
80
}
82
81
```
83
82
84
-
If you intend to use send data via **Http** you should set **HecConfiguration** section and if you choose to send data via socket you must set **SocketConfiguration** section.
83
+
If you intend to send data via **Http** you should set **HecConfiguration** section and if you choose to send data via socket you must set **SocketConfiguration** section.
85
84
86
-
Now we need to configure SplunkLoggerConfiguration and indicate to use **Splunk** section from configuration file.
85
+
Now we need to configure SplunkLoggerConfiguration at dependency injection and indicate to use **Splunk** section from configuration file.
87
86
```csharp
88
87
/// <summary>
89
88
/// This method gets called by the runtime. Use this method to add services to the container.
If you intend to use send data via **Http** you should set **HecConfiguration** property and if you choose to send data via socket you must set **SocketConfiguration** property.
142
+
Again, if you intend to use send data via **Http** you should set **HecConfiguration** property and if you choose to send data via socket you must set **SocketConfiguration** property.
144
143
145
-
### Sample Logging
144
+
### Logging
146
145
147
-
At controller you must receive `ILoggerFactory loggerFactory` and extract `ILogger`from it and use this `ILogger` instance to log any desired event, as sample below:
146
+
Now that everything is configured and ILoggerFactory already have the desired ILogger instance added you can log your messages.
147
+
148
+
Here is a sample of how you can log messages, in this case I'm logging a `NotImplementedException` at [SampleWebAPI project](https://github.com/vtex/SplunkLogger/tree/master/src/SampleWebAPI)`ValuesController`.
148
149
149
150
```csharp
150
151
[Route("api/[controller]")]
@@ -167,6 +168,6 @@ public class ValuesController : Controller
167
168
}
168
169
```
169
170
170
-
### Sending Http Events As Batchs
171
+
##More Information
171
172
172
-
**To Be Definied**
173
+
You can read more about the projects and it's details at [Wiki page](https://github.com/vtex/SplunkLogger/wiki)
0 commit comments