Appenders for .NET logging frameworks which send data to Sumo Logic HTTP sources.
Appenders are provided for the following .NET logging frameworks
All appenders have two implementations: a buffering and a non-buffering version. The non-buffering implementations will send each log message to Sumo Logic in a distinct HTTP request. The buffering implementations will queue messages until a size, count, or time threshold is met, then send in batch.
To install the NLog target, use the following steps
Install-Package SumoLogic.Logging.NLogExample Appender Configuration for NLog
<?xml version="1.0" encoding="utf-8" ?> <nlog autoReload="true" internalLogToConsole="true"> <extensions> <add assembly="SumoLogic.Logging.NLog"/> </extensions> <targets> <target name="sumoLogic" type="SumoLogicTarget" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff} ${level}, ${message}${exception:format=tostring}${newline}"> <Url>https://collectors.us2.sumologic.com/receiver/v1/http/==your_endpoint_here==</Url> <ConnectionTimeout>30000</ConnectionTimeout> <SourceName>ExampleNameNLogTarget</SourceName> <SourceCategory>ExampleCategoryNLogTarget</SourceCategory> <SourceHost>ExampleHostNLogTarget</SourceHost> <UseConsoleLog>true</UseConsoleLog> </target> <target name="bufferedSumoLogic" type="BufferedSumoLogicTarget" layout="${date:format=yyyy-MM-dd HH\:mm\:ss.fff} ${level}, ${message}${exception:format=tostring}${newline}"> <Url>https://collectors.us2.sumologic.com/receiver/v1/http/==your_endpoint_here==</Url> <SourceName>ExampleNameNLogBufferedTarget</SourceName> <SourceCategory>ExampleCategoryNLogBufferedTarget</SourceCategory> <SourceHost>ExampleHostNLogBufferedTarget</SourceHost> <ConnectionTimeout>30000</ConnectionTimeout> <RetryInterval>5000</RetryInterval> <MessagesPerRequest>10</MessagesPerRequest> <MaxFlushInterval>10000</MaxFlushInterval> <FlushingAccuracy>250</FlushingAccuracy> <MaxQueueSizeBytes>500000</MaxQueueSizeBytes> <UseConsoleLog>true</UseConsoleLog> </target> </targets> <rules> <logger name="*" minLevel="Debug" writeTo="sumoLogic"/> <logger name="*" minLevel="Debug" writeTo="bufferedSumoLogic"/> </rules> </nlog>
public static class Program { /// <summary> /// An example application that logs. /// </summary> public static void Main() { Logger logger = LogManager.GetCurrentClassLogger(); logger.Debug("Log message"); Console.Read(); } }
More about NLog target configuration: SumoLogic.Logging.NLog
To install the Log4Net appender, use the following steps:
Install-Package SumoLogic.Logging.Log4NetExample Appender Configuration for Log4Net
<configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net debug="true"> <appender name="SumoLogicAppender" type="SumoLogic.Logging.Log4Net.SumoLogicAppender, SumoLogic.Logging.Log4Net"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/> </layout> <Url value="https://collectors.us2.sumologic.com/receiver/v1/http/==your_endpoint_here==" /> <ConnectionTimeout value="30000" /> <!-- in milliseconds --> <SourceName value="ExampleNameLog4NetAppender" /> <SourceCategory value="ExampleCategoryLog4NetAppender" /> <SourceHost value="ExampleHostLog4NetAppender" /> <UseConsoleLog value="true" /> </appender> <appender name="BufferedSumoLogicAppender" type="SumoLogic.Logging.Log4Net.BufferedSumoLogicAppender, SumoLogic.Logging.Log4Net"> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/> </layout> <Url value="https://collectors.us2.sumologic.com/receiver/v1/http/==your_endpoint_here==" /> <SourceName value="ExampleNameLog4NetBufferedAppender" /> <SourceCategory value="ExampleCategoryLog4NetBufferedAppender" /> <SourceHost value="ExampleHostLog4NetBufferedAppender" /> <ConnectionTimeout value="30000" /> <RetryInterval value="5000" /> <MessagesPerRequest value="10" /> <MaxFlushInterval value="10000" /> <FlushingAccuracy value="250" /> <MaxQueueSizeBytes value="500000" /> <UseConsoleLog value="true" /> </appender> <root> <priority value="ALL"/> <level value="ALL"/> <appender-ref ref="SumoLogicAppender"/> <appender-ref ref="BufferedSumoLogicAppender"/> </root> <logger name="SumoLogic.Logging.Log4Net.Example.Program"> <level value="ALL"/> </logger> </log4net> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration>
public static class Program { /// <summary> /// The log4net log. /// </summary> private static ILog log4netLog = LogManager.GetLogger(typeof(Program)); /// <summary> /// An example application that logs. /// </summary> public static void Main() { Console.WriteLine("Hello world!"); log4netLog.Info("Hello world!"); Console.ReadKey(); } }
More about Log4Net appender configuration: SumoLogic.Logging.Log4Net
To install the Serilog sink, use the following steps:
Install-Package SumoLogic.Logging.SerilogExample Code (instantiation and configuration)
Logger log = new LoggerConfiguration() .WriteTo.BufferedSumoLogic( new Uri("https://collectors.us2.sumologic.com/receiver/v1/http/==your_endpoint_here=="), sourceName: "ExampleNameSerilogBufferedSink", sourceCategory: "ExampleCategorySerilogBufferedSink", sourceHost: "ExampleHostSerilogBufferedSink", connectionTimeout: 30000, retryInterval: 5000, messagesPerRequest: 10, maxFlushInterval: 10000, flushingAccuracy: 250, maxQueueSizeBytes: 500000) .CreateLogger(); log.Information("Hello world!");
More about Serilog sink configuration: SumoLogic.Logging.Serilog
ASP.NET Core Logging ProviderTo install the logging provider, use the following steps:
Install-Package SumoLogic.Logging.AspNetCore
More about ASP.NET Core logging provider configuration: SumoLogic.Logging.AspNetCore
Sumo Logic only accepts connections from clients using TLS version 1.2 or greater. To utilize the content of this repo, ensure that it's running in an execution environment that is configured to use TLS 1.2 or greater.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4