Jump to: navigation, search

Difference between revisions of "Serilog"


Line 70: Line 70:
 
|}
 
|}
 
**Added a way for the User to configure the default log path, the file count limit, the log event level and rolling policies through Logger.config with changing only the “values”, which are set on their default.
 
**Added a way for the User to configure the default log path, the file count limit, the log event level and rolling policies through Logger.config with changing only the “values”, which are set on their default.
**The default Log path is set to C:\Users\.......\source\repos\UBIK.Server\Branches\.......\UBIK.Studio\bin\Debug\Logs and its values can be changed to any local path(e.g. value="C:\logs") or it can be changed using the Environment Variables (e.g. value="%SYSTEMDRIVE%\logs").
+
**The default Log path is set to the installation directory of UBIK. Its value can be changed to any local path (e.g. value="C:\logs"). Using OS Environment Variables (e.g. value="%SYSTEMDRIVE%\logs") is possible.
 
**The default for the event level is set to Debug and its values can be changed to Verbose, Information, Warning, Error or Fatal.
 
**The default for the event level is set to Debug and its values can be changed to Verbose, Information, Warning, Error or Fatal.
 
**File default count limit is set to 31 and its values can be changed to any positive number.
 
**File default count limit is set to 31 and its values can be changed to any positive number.

Revision as of 11:49, 5 August 2020

Serilog is a portable and structured logging framework to record diagnostic logs into files, console and SQL/NoSQL databases.


[edit]

Description

Serilog
Name Serilog
Purpose Structured logging framework to record diagnostic logs into files, console and SQL/NoSQL databases.
Category UBIK
Returns void
Version 3.6.0+

Serilog existing log event levels

LogLevel Purpose
Verbose It is the noisiest level, generally used only as a last resort when debugging a difficult problem, and rarely (if ever) enabled for a production app. For example, local variables within an algorithm implementation might be logged at this level.
Debug Debug is used for internal system events that are not necessarily observable from the outside, but useful when determining how something happened. For example, the details of requests and responses made to and from external integration points would often be logged at this level.
Information Information events describe things happening in the system that correspond to its responsibilities and functions. Generally, these are the observable actions the system can perform. For example, processing a payment or updating a user's details will be logged at this level.
Warning When service is degraded, endangered, or may be behaving outside of its expected parameters, Warning level events are used. A warning event should only be emitted when the condition is either transient or can be investigated and fixed - use restraint to avoid polluting the log with spurious warnings. For example, slow response times from a critical database would be logged as warnings.
Error When functionality is unavailable or expectations broken, an Error event is used. For example, receiving an exception when trying to commit a database transaction is an event at this level.
Fatal The most critical level, Fatal events demand immediate attention. For example, an application failing during startup will log a Fatal event. If you have a pager, it goes off when one of these occurs.


Usage

Used to replace our existing Microsoft.Practices.EnterpriseLibrary.Logging with more up-to-date solution like Serilog.

NewFeatures

  • We replaced all the code that uses the Microsoft.Practices.EnterpriseLibrrary.Logging library with the Serilog library.

Logging methods used in UBIKKernel

MethodName Level Purpose
LogVerbose Verbose method for writing a verbose log message to the output log file logged as Verbose event level. (new)
LogDebugOutput Debug method for writing a debug log message to the output log file logged as Debug event level.
LogInformation Information method for writing an information log message to the output log file logged as Information event level. (new)
LogSQLStatement LogSQLCommand Information method for writing a sql log message to the output log file logged as Information event level.
LogCustomizing Information method for writing a customizing log message to the output log file logged as Information event level.
LogService Information method for writing a customizing log message to the output log file logged as Information event level.
LogWorkflowOutput Information method for writing a service log message to the output log file logged as Information event level.
ThrowAssertion Warning method for writing an assertion log message to the output log file logged as Information event level.
LogWarning Warning method for writing a warning log message to the output log file logged as Warning event level.
LogError Error method for writing an error log message to the output log file logged as Error event level. (new)
LogException Error method for writing an exception log message to the output log file logged as Error event level.
LogFatal Fatal method for writing a fatal log message to the output log file logged as Fatal event level. (new)
    • Added a way for the User to configure the default log path, the file count limit, the log event level and rolling policies through Logger.config with changing only the “values”, which are set on their default.
    • The default Log path is set to the installation directory of UBIK. Its value can be changed to any local path (e.g. value="C:\logs"). Using OS Environment Variables (e.g. value="%SYSTEMDRIVE%\logs") is possible.
    • The default for the event level is set to Debug and its values can be changed to Verbose, Information, Warning, Error or Fatal.
    • File default count limit is set to 31 and its values can be changed to any positive number.
    • The default Rolling policies is set to Day and its values can be changed to "Day", "Month" or "Year".


Example

Exemplary values to get Customizing log message using Who-Bert.


               public class ObjectTest
               {
                              public void TestObject (params BaseClass[] InVariables)
                              {
                                              
                                              //Example using static class debugger
                                              Debugger.Output(this, "*** Started");
                                              foreach (BaseClass obj in InVariables)
                                              {
                                                            
  
                                                              // LogCustomizing
                                                              UBIK.Kernel.UBIKKernel.LogCustomizing(System.Reflection.MethodBase.GetCurrentMethod(), "TEST");
                                                               
                                                              Debugger.Output(this, obj.Name + " " + obj.Description);
                                              }
                                              Debugger.Output(this, "*** Finished");
                              }
               }


  • Expected Result :

[22/06/2020 09:21:55]
TEST 
Id = [0] 
UBIK.Whobert.637284145138731645.dll   Void TestObject(UBIK.Kernel.BaseClass[]) 


See also


Useful links [What is Serilog]