From 2ab6a5dd35e7b27f362945d5d8b1b0c032c9fc12 Mon Sep 17 00:00:00 2001 From: ShiranAvidov <48657224+ShiranAvidov@users.noreply.github.com> Date: Thu, 23 Jun 2022 10:38:07 +0300 Subject: [PATCH] Update log4net.md --- docs/log4net.md | 64 ++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/log4net.md b/docs/log4net.md index 46a8764..c2746b3 100644 --- a/docs/log4net.md +++ b/docs/log4net.md @@ -68,22 +68,22 @@ Add a reference to the configuration file in your code, as shown in the example To add the Logz.io appender via code, add the following lines: ```C# - var hierarchy = (Hierarchy)LogManager.GetRepository(); - var logzioAppender = new LogzioAppender(); - logzioAppender.AddToken("<>"); - logzioAppender.AddListenerUrl("<>"); - // <-- Uncomment and edit this line to enable proxy routing: --> - // logzioAppender.AddProxyAddress("http://your.proxy.com:port"); - // <-- Uncomment this to enable sending logs in Json format --> - // logzioAppender.ParseJsonMessage(true); - // <-- Uncomment these lines to enable gzip compression --> - // logzioAppender.AddGzip(true); - // logzioAppender.ActivateOptions(); - // logzioAppender.JsonKeysCamelCase(false) - logzioAppender.ActiveOptions(); - hierarchy.Root.AddAppender(logzioAppender); - hierarchy.Root.Level = Level.All; - hierarchy.Configured = true; +var hierarchy = (Hierarchy)LogManager.GetRepository(); +var logzioAppender = new LogzioAppender(); +logzioAppender.AddToken("<>"); +logzioAppender.AddListenerUrl("<>"); +// <-- Uncomment and edit this line to enable proxy routing: --> +// logzioAppender.AddProxyAddress("http://your.proxy.com:port"); +// <-- Uncomment this to enable sending logs in Json format --> +// logzioAppender.ParseJsonMessage(true); +// <-- Uncomment these lines to enable gzip compression --> +// logzioAppender.AddGzip(true); +// logzioAppender.ActivateOptions(); +// logzioAppender.JsonKeysCamelCase(false) +logzioAppender.ActiveOptions(); +hierarchy.Root.AddAppender(logzioAppender); +hierarchy.Root.Level = Level.All; +hierarchy.Configured = true; ``` ## Custom Fields @@ -91,16 +91,16 @@ To add the Logz.io appender via code, add the following lines: You can add static keys and values to be added to all log messages. For example: ```XML - - - Environment - Production - - - Location - New Jerseay B1 - - + + + Environment + Production + + + Location + New Jerseay B1 + + ``` ## Extensibility @@ -108,14 +108,14 @@ You can add static keys and values to be added to all log messages. For example: If you want to change some of the fields or add some of your own, inherit the appender and override the `ExtendValues` method: ```C# - public class MyAppLogzioAppender : LogzioAppender +public class MyAppLogzioAppender : LogzioAppender +{ + protected override void ExtendValues(LoggingEvent loggingEvent, Dictionary values) { - protected override void ExtendValues(LoggingEvent loggingEvent, Dictionary values) - { - values["logger"] = "MyPrefix." + values["logger"]; - values["myAppClientId"] = new ClientIdProvider().Get(); - } + values["logger"] = "MyPrefix." + values["logger"]; + values["myAppClientId"] = new ClientIdProvider().Get(); } +} ``` You will then have to change your configuration in order to use your own appender.