Difference between revisions of "Serilog"
(→NewFeatures) |
|||
(57 intermediate revisions by 2 users not shown) | |||
Line 9: | Line 9: | ||
| imagecaption = | | imagecaption = | ||
| purpose = Structured logging framework to record diagnostic logs into files, console and SQL/NoSQL databases. | | purpose = Structured logging framework to record diagnostic logs into files, console and SQL/NoSQL databases. | ||
+ | | returns = void | ||
| category = UBIK | | category = UBIK | ||
− | | version = 3. | + | | version = 3.6.0+ |
}} | }} | ||
− | === | + | ===Serilog existing log event levels=== |
+ | *Log Levels taken from the Serilog doku : https://github.com/serilog/serilog/wiki/Configuration-Basics | ||
{| class="wikitable sortable" | width = "50%" | {| class="wikitable sortable" | width = "50%" | ||
|- | |- | ||
− | ! | + | ! LogLevel !! Purpose |
|- align="left" | |- align="left" | ||
− | | Verbose || 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. | + | | 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. |
|- align="left" | |- align="left" | ||
| 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. | | 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. | ||
Line 32: | Line 34: | ||
|} | |} | ||
− | + | ===Logging methods used in UBIKKernel=== | |
− | === | + | |
− | + | ||
− | === | + | |
− | + | ||
− | + | ||
− | + | ||
{| class="wikitable sortable" | width = "50%" | {| class="wikitable sortable" | width = "50%" | ||
|- | |- | ||
− | ! | + | ! MethodName !! Level !! Purpose |
|- align="left" | |- align="left" | ||
| LogVerbose || Verbose || method for writing a verbose log message to the output log file logged as Verbose event level. (new) | | LogVerbose || Verbose || method for writing a verbose log message to the output log file logged as Verbose event level. (new) | ||
Line 49: | Line 45: | ||
| LogInformation || Information || method for writing an information log message to the output log file logged as Information event level. (new) | | LogInformation || Information || method for writing an information log message to the output log file logged as Information event level. (new) | ||
|- align="left" | |- align="left" | ||
− | + | | LogSQLStatement LogSQLCommand || Information || method for writing a sql log message to the output log file logged as Information event level. | |
− | + | ||
− | | LogSQLStatement | + | |
|- align="left" | |- align="left" | ||
| LogCustomizing || Information || method for writing a customizing 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. | ||
Line 57: | Line 51: | ||
| LogService || 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. | ||
|- align="left" | |- align="left" | ||
− | | | + | | LogWorkflowOutput || Information || method for writing a service log message to the output log file logged as Information event level. |
|- align="left" | |- align="left" | ||
− | | | + | | ThrowAssertion || Warning || method for writing an assertion log message to the output log file logged as Information event level. |
|- align="left" | |- align="left" | ||
− | | | + | | LogWarning || Warning || method for writing a warning log message to the output log file logged as Warning event level. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | | | + | |
− | + | ||
|- align="left" | |- align="left" | ||
− | | | + | | LogError || Error || method for writing an error log message to the output log file logged as Error event level. (new) |
|- align="left" | |- align="left" | ||
− | | Error || | + | | LogException || Error || method for writing an exception log message to the output log file logged as Error event level. |
|- align="left" | |- align="left" | ||
− | | | + | | LogFatal || Fatal || method for writing a fatal log message to the output log file logged as Fatal event level. (new) |
− | | | + | |
− | | | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- align="left" | |- align="left" | ||
|} | |} | ||
+ | |||
+ | === How To Configure Logging === | ||
+ | |||
+ | *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. | ||
+ | **Using Relative path's (e.g. value="..\logs" used for moving up in the hierarchy from the current directory) or (e.g. value=".\logs" represents the current directory itself) 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". | ||
+ | |||
+ | <source lang="xml"> | ||
+ | |||
+ | <LoggingConfiguration> | ||
+ | <add key="LogRootPath" value=""/> | ||
+ | <!-- Values can be "Verbose", "Debug", "Information", "Warning", "Error", "Fatal". Normally "Debug" should be fine and you should only change if you know well what you do. --> | ||
+ | <add key="LogLevel" value="Debug"/> | ||
+ | <!-- The most recent 31 files are retained by default (i.e. one long month). If the value is empty the default will be applied. You must specifically set value="null" to remove this limit and all log files will be kept. You can set any other positive number --> | ||
+ | <add key="RetainedFileCountLimit" value="31"/> | ||
+ | <!-- Value can be either "Day", "Month" or "Year". Default is "Day"--> | ||
+ | <add key="RollingInterval" value="Day"/> | ||
+ | </LoggingConfiguration> | ||
+ | |||
+ | </source> | ||
+ | |||
+ | |||
+ | |||
+ | === Since Version 3.6 === | ||
+ | Replace our existing Microsoft.Practices.EnterpriseLibrary.Logging with more up-to-date solution like Serilog. | ||
+ | |||
+ | |||
+ | |||
+ | =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[]) | ||
<!-- DO NOT REMOVE THIS -->{{Template:Activity/End}}<!-- DO NOT REMOVE THIS --> | <!-- DO NOT REMOVE THIS -->{{Template:Activity/End}}<!-- DO NOT REMOVE THIS --> | ||
− | == | + | ===How to configure logging Version 3.5 or erlier=== |
− | * [[ | + | * [[Configuration_Files/Logging.config]] |
+ | * [[HowTo:Configure_Logging]] | ||
− | ==Useful links [What is Serilog | + | |
+ | |||
+ | ===Useful links [What is Serilog]=== | ||
* https://serilog.net/ | * https://serilog.net/ | ||
+ | {{Category/Version|3.6.0}} | ||
+ | |||
+ | [[Category:3.6.0|Serilog]] |
Latest revision as of 08:52, 16 November 2020
Serilog is a portable and structured logging framework to record diagnostic logs into files, console and SQL/NoSQL databases.
How to configure logging Version 3.5 or erlier