Skip to content

gRPC Log Server (Windows Services) to receive and then forward messages to Analogy Log Viewer

License

Notifications You must be signed in to change notification settings

Analogy-LogViewer/Real-Time-Log-Server

Repository files navigation

Analogy Log Server Codacy Badge

.NET Core Desktop Issues GitHub closed issues License

gRPC Log Server (Windows Services) to receive and then forward messages to Analogy Log Viewer.

Analogy Log server supports the following real time data:

  • Windows Event logs (configurable in the server settings)
  • Any gRPC client that implements the Proto file (currentlly there are fully implemented C#, Python and JAVA (Poc) clients)

The following modules exists:

Nuget Version Description
Analogy.LogViewer.gRPC Nuget Primary Analogy Log Viewer grRPC providers
Analogy.LogServer Nuget A windows Service for receiving logs
Analogy.LogServer.Clients Nuget gRPC client to pull back messages from Analogy Service
Analogy.AspNetCore.LogProvider Nuget AspNetCore Logger provider
NLog Target Nuget NLog target to stream logs to Analogy
Serilog Sink Nuget Serilog Sink for sending logs to Analogy

There are, currently, 4 types of gRPC clients:

Data Provider Nuget Version
NLog Target NLog target to stream logs to Analogy
Serilog Sink Serilog Sink for sending logs to Analogy
Analogy.AspNetCore.LogProvider Custom logging provider in Asp.Net Core that write logs to Analogy
Python Logging Python gRPC client logger that sends logs to Analogy

Windows Service:

Example

With Analogy Log server you can stream log messages from any Supported languages and have them saved in a log files and view in real time using Analogy Log Viewer.

Usage

Once you have setup Analogy Log Server you can start sending messages to it:

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     autoReload="true"
     internalLogLevel="warn">

 <extensions>
   <add assembly="NLog.Web.AspNetCore"/>
   <add assembly="Analogy.LogViewer.NLog.Targets"/>
 </extensions>

 <targets>
   <!-- write logs to file  -->
   <target xsi:type="File" name="allfile"
       fileName="c:\KALPA\logs\${processname:fullName=false}-KX.nlog"
       layout="${longdate}|${uppercase:${level}}|${logger}|${message}${exception:format=tostring}|${processname:fullName=false}|${processid}"
       keepFileOpen="false"
       archiveFileName="c:\KALPA\logs\${processname:fullName=false}-KX-${shortdate}.{##}.nlog"
       archiveNumbering="Sequence"
       archiveEvery="Day"
       maxArchiveFiles="100"
       archiveAboveSize="30000000">
   </target>
   <!-- write logs to Analogy Log Server  -->
   <target xsi:type="NlogAnalogyGRPCTarget" name="NLogToAnalogyGRPCTarget"
           layout="${longdate}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|${processname:fullName=false}|${processid}">
     <contextproperty name="MachineName" layout="${machinename}" />
     <contextproperty name="ThreadId" layout="${threadid}"/>
     <contextproperty name="ProcessId" layout="${processid}" />
     <contextproperty name="callsite" layout="   ${callsite:className=true:fileName=true:includeSourcePath=true:methodName=true}" />
     <contextproperty name="ProcessName" layout="${processname:fullName=false}" />
   </target>
 </targets>

 <rules>
   <logger name="*" minlevel="Trace" writeTo="allfile" />
   <logger name="*" minlevel="Trace" writeTo="NLogToAnalogyGRPCTarget" />
 </rules>
</nlog>
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
 {
     loggerFactory.AddAnalogyLogger(new AnalogyLoggerConfiguration
     {
         LogLevel = LogLevel.Trace,
         EventId = 0,
         AnalogyServerUrl = "http://localhost:6000"
      });
     }

you can see forbbiden port by running:

netsh interface ipv4 show excludedportrange protocol=tcp