<commit_before># UDP Forwarder for Web API

## About ##
The udp-forwarder is an open source library available as a [NuGet package](https://www.nuget.org/packages/UDPForwarder/) for Web APIs. It grabs http requests sent to the API, creates a rich log event in a JSON format and sends it to a remote log service, like Logstash, via UDP.

## Usage ##
To install the udp-forwarder to your WebAPI project: 
* Run "Install-Package udp-forwarder" in the Package Manager Console.
* Add the following to App_Start/WebAPIConfig.cs.
```csharp
var serverIp = "0.0.0.0";
var serverPort = 0000;
var logService = new LogService(new UDPService(serverIp, serverPort));
config.MessageHandlers.Add(new LoggingHandler(logService));
```
* Edit the serverIP and serverPort variables to match the setup of your log service.
* OPTIONAL: If for some reason the forwarder cannot send the log to the remote log service, then that log is dismissed. This is the default configuration but there is an optional feature to log these instances to a text file. To enable this feature, add the following key to appSettings of the WebAPI's Web.config file, where the value points to the desired directory where the logs should be stored.
```csharp
<add key="FallbackLogPath" value="c:/logs">
```

* Save and run the API.
<commit_msg>updated the guide to take into account that the server ip and port has moved into Web.config<commit_after># UDP Forwarder for Web API

## About ##
The udp-forwarder is an open source library available as a [NuGet package](https://www.nuget.org/packages/UDPForwarder/) for Web APIs. It grabs http requests sent to the API, creates a rich log event in a JSON format and sends it to a remote log service, like Logstash, via UDP.

## Usage ##
To install the udp-forwarder to your WebAPI project: 
* Run "Install-Package udp-forwarder" in the Package Manager Console.
* Add the following to App_Start/WebAPIConfig.cs.
```csharp
var serverIp = WebConfigurationManager.AppSettings["UdpLogForwarderIP"];
var serverPort = Int32.Parse(WebConfigurationManager.AppSettings["UdpLogForwarderPort"]); ;
var logService = new LogService(new UDPService(serverIp, serverPort));
config.MessageHandlers.Add(new LoggingHandler(logService));
```
* Add the following to appSettings of the WebAPI's Web.config file.
var serverIp = WebConfigurationManager.AppSettings["UdpLogForwarderIP"];
```csharp
<add key="UdpLogForwarderIP" value="0.0.0.0" />
<add key="UdpLogForwarderPort" value="0000" /> 
```
* Edit the UdpLogForwarderIP and UdpLogForwarderPort values to match the setup of your log service.
* OPTIONAL: If for some reason the forwarder cannot send the log to the remote log service, then that log is dismissed. This is the default configuration but there is an optional feature to log these instances to a text file. To enable this feature, add the following key to appSettings of the WebAPI's Web.config file, where the value points to the desired directory where the logs should be stored.
```csharp
<add key="FallbackLogPath" value="c:/logs">
```

* Save and run the API.

{'fraction_non_alphanumeric': 0.08183306055646482, 'fraction_numerical': 0.005891980360065467, 'mean_word_length': 5.0276134122287965, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6009732', 'n_tokens_mistral': 881, 'n_tokens_neox': 840, 'n_words': 398}