Skip to content

Commit

Permalink
Use static http client (#2478)
Browse files Browse the repository at this point in the history
* Updated Azure serverless function code sample titles

* Add UseStaticHttpClient & update serverless section.

* Update dotnet.md (#2479)
  • Loading branch information
ralongit authored Oct 23, 2023
1 parent a2a5d8b commit 1a8a3f7
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions _source/logzio_collections/_log-sources/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contributors:
- imnotashrimp
- savidov
- yberlinger
- ralongit
shipping-tags:
- from-your-code
order: 230
Expand Down Expand Up @@ -100,6 +101,9 @@ For a complete list of options, see the configuration parameters below the code
<jsonKeysCamelCase>false</jsonKeysCamelCase>
<!-- Add trace context (traceId and spanId) to each log. The default is false -->
<addTraceContext>false</addTraceContext>
<!-- Use the same static HTTP/s client for sending logs. The default is false -->
<UseStaticHttpClient>false</addTraceContext>

</appender>

<root>
Expand Down Expand Up @@ -158,6 +162,7 @@ logzioAppender.AddListenerUrl("<<LISTENER-HOST>>");
// logzioAppender.ActivateOptions();
// logzioAppender.JsonKeysCamelCase(false);
// logzioAppender.AddTraceContext(false);
// logzioAppender.UseStaticHttpClient(false);
logzioAppender.ActivateOptions();
hierarchy.Root.AddAppender(logzioAppender);
hierarchy.Root.Level = Level.All;
Expand Down Expand Up @@ -194,6 +199,7 @@ namespace dotnet_log4net
// logzioAppender.ActivateOptions();
// logzioAppender.JsonKeysCamelCase(false)
// logzioAppender.AddTraceContext(false);
// logzioAppender.UseStaticHttpClient(false);
logzioAppender.ActivateOptions();

hierarchy.Root.AddAppender(logzioAppender);
Expand Down Expand Up @@ -227,6 +233,7 @@ namespace dotnet_log4net
| proxyAddress | Proxy address to route your logs through. | `None` |
| jsonKeysCamelCase | If you have custom fields keys that start with a capital letter and want to see the fields with a capital letter in Logz.io, set this field to true. | `false` |
| addTraceContext | If want to add trace context to each log, set this field to true. | `false` |
| useStaticHttpClient | If want to use the same static HTTP/s client for sending logs, set this field to true. | `false` |


</div>
Expand Down Expand Up @@ -302,6 +309,8 @@ namespace dotnet_log4net
// logzioAppender.AddGzip(true);
// logzioAppender.ActivateOptions();
// logzioAppender.JsonKeysCamelCase(false)
// logzioAppender.UseStaticHttpClient(false);
logzioAppender.AddTraceContext(true);
logzioAppender.ActivateOptions();

Expand All @@ -320,8 +329,7 @@ namespace dotnet_log4net
```

### Serverless platforms
If you’re using a serverless function, you’ll need to call the appender's flush methods at the end of the function run to make sure the logs are sent before the function finishes its execution. You’ll also need to create a static appender in the Startup.cs file so each invocation will use the same appender.
Make sure 'debug' is set to false if the function is deployed as it might cause permission issues with debug files.
If you’re using a serverless function, you’ll need to call the appender's flush method at the end of the function run to make sure the logs are sent before the function finishes its execution. You’ll also need to create a static appender in the Startup.cs file so each invocation will use the same appender. The appender should have the `UseStaticHttpClient` flag set to `true`.

###### Azure serverless function code sample
*Startup.cs*
Expand All @@ -344,6 +352,7 @@ namespace LogzioLog4NetSampleApplication
logzioAppender.AddToken("<<LOG-SHIPPING-TOKEN>>");
logzioAppender.AddListenerUrl("https://<<LISTENER-HOST>>:8071");
logzioAppender.ActivateOptions();
logzioAppender.UseStaticHttpClient(true);
hierarchy.Root.AddAppender(logzioAppender);
hierarchy.Configured = true;
}
Expand Down Expand Up @@ -446,8 +455,9 @@ For a complete list of options, see the configuration parameters below the code
jsonKeysCamelCase="false"
addTraceContext="false"
<!-- parseJsonMessage="true"-->
>
<contextproperty name="host" layout="${machinename}" />
<!-- useStaticHttpClient="false"-->
>
<contextproperty name="host" layout="${machinename}" />
<contextproperty name="threadid" layout="${threadid}" />
</target>
</targets>
Expand Down Expand Up @@ -476,7 +486,8 @@ var logzioTarget = new LogzioTarget {
JsonKeysCamelCase = false,
AddTraceContext = false,
// ParseJsonMessage = true,
// ProxyAddress = "http://your.proxy.com:port"
// ProxyAddress = "http://your.proxy.com:port",
// UseStaticHttpClient = false,
};

config.AddRule(LogLevel.Debug, LogLevel.Fatal, logzioTarget);
Expand All @@ -499,6 +510,7 @@ LogManager.Configuration = config;
| proxyAddress | Proxy address to route your logs through. | `None` |
| jsonKeysCamelCase | If you have custom fields keys that start with a capital letter and want to see the fields with a capital letter in Logz.io, set this field to true. | `false` |
| addTraceContext | If want to add trace context to each log, set this field to true. | `false` |
| useStaticHttpClient | If want to use the same static HTTP/s client for sending logs, set this field to true. | `false` |

###### Code sample

Expand Down Expand Up @@ -601,15 +613,15 @@ var logzioTarget = new LogzioTarget {
AddTraceContext = true,
// ParseJsonMessage = true,
// ProxyAddress = "http://your.proxy.com:port"
};

config.AddRule(LogLevel.Debug, LogLevel.Fatal, logzioTarget);
LogManager.Configuration = config;
```

##### Serverless platforms
If you’re using a serverless function, you’ll need to call the appender's flush methods at the end of the function run to make sure the logs are sent before the function finishes its execution. You’ll also need to create a static appender in the Startup.cs file so each invocation will use the same appender.
Make sure 'debug' is set to false if the function is deployed as it might cause permission issues with debug files.
If you’re using a serverless function, you’ll need to call the appender's flush method at the end of the function run to make sure the logs are sent before the function finishes its execution. You’ll also need to create a static appender in the Startup.cs file so each invocation will use the same appender. The appender should have the `UseStaticHttpClient` flag set to `true`.

###### Azure serverless function code sample

Expand Down Expand Up @@ -646,6 +658,7 @@ namespace LogzioNLogSampleApplication
Debug = false,
JsonKeysCamelCase = false,
AddTraceContext = false,
UseStaticHttpClient = true,
// ParseJsonMessage = true,
// ProxyAddress = "http://your.proxy.com:port"
};
Expand Down Expand Up @@ -765,6 +778,9 @@ For a complete list of options, see the configuration parameters below the code
<jsonKeysCamelCase>false</jsonKeysCamelCase>
<!-- Add trace context (traceId and spanId) to each log. The default is false -->
<addTraceContext>false</addTraceContext>
<!-- Use the same static HTTP/s client for sending logs. The default is false -->
<useStaticHttpClient>false</useStaticHttpClient>

</appender>

<root>
Expand All @@ -788,6 +804,7 @@ logzioAppender.AddListenerUrl("<<LISTENER-HOST>>");
// logzioAppender.ActivateOptions();
// logzioAppender.JsonKeysCamelCase(false);
// logzioAppender.AddTraceContext(false);
// logzioAppender.UseStaticHttpClient(false);
logzioAppender.ActivateOptions();
hierarchy.Root.AddAppender(logzioAppender);
hierarchy.Root.Level = Level.All;
Expand All @@ -811,6 +828,7 @@ hierarchy.Configured = true;
| proxyAddress | Proxy address to route your logs through. | `None` |
| jsonKeysCamelCase | If you have custom fields keys that start with capital letter and want to see the fields with capital letter in Logz.io, set this field to true. | `false` |
| addTraceContext | If want to add trace context to each log, set this field to true. | `false` |
| useStaticHttpClient | If want to use the same static HTTP/s client for sending logs, set this field to true. | `false` |

###### Code sample

Expand Down

0 comments on commit 1a8a3f7

Please sign in to comment.