Log configuration file location
- Project > Service > 4-Interface > ${package name} > catsserilog.json
Analysing catsserilog.json file
- This application logging mechanism is based on serilog logging framework which is one of common logging framework of .Net applications.
- Reference
Top logging frameworks for .NET applications & the best config tips view
A library of top logging frameworks for .Net core applications, Nlog, SeriLog, Log4Net; and the best configuration tips from developer's view
enlabsoftware.com
- This is the serilog.json file for the application.
- To understand for the serilog.json file, the comments for the script are attached.
{
"Serilog": { //Defining the logging framework
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], //Defining which log types are provided
"MinimumLevel": "Information", //Minimum log level is Info level
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": { "path": "Logs/log.txt" } //Defining the log directory where the application log file will be stored in
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Destructure": [ //Defining log management policy
{
"Name": "ToMaximumDepth",
"Args": { "maximumDestructuringDepth": 3 }
},
{
"Name": "ToMaximumStringLength",
"Args": { "maximumStringLength": 10 }
},
{
"Name": "ToMaximumCollectionCount",
"Args": { "maximumCollectionCount": 5 }
}
],
"Properties": {
"Application": "Sample"
}
}
}
- maximumDestructuringDepth
- maximumStringLength
- maximumCollectionCount
The example of configuring the log management policies
- This configuration is not set up at the application serilog.json file. but It shows that the log file life cycle like rolling based on the day can be managed by some configuration.
{
"AllowedHosts": "*",
"Serilog": {
"Using": [],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
}
},
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "Logs/log.txt",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:G} {Message}{NewLine:1}{Exception:1}"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/log.json",
"rollingInterval": "Day",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog"
}
}
]
}
}
- Reference site
https://achrafbenalaya.com/2020/09/13/setting-up-serilog-in-asp-net-core/
Setting up Serilog in ASP.NET Core
WHAT TO LOG It is not enough to log errors in order to use them for troubleshooting purposes. It is
achrafbenalaya.com
Analysis Pod log
- Check the pod description
root@dintopdep01:/# kubectl describe pod cots-core-casemanagement-api-848bddcdd5-hr5zh -n cots-core
- Check the Container ID
Name: cots-core-casemanagement-api-848bddcdd5-hr5zh
Namespace: cots-core
<...>
Controlled By: ReplicaSet/cots-core-casemanagement-api-848bddcdd5
Containers:
casemanagement:
Container ID: docker://d10c4f5cc1d87f1fbcb12ed4ee1df3699a47e6c69f08a34cc25f95b7ad772fab
<...>
Kubernetes log file max-file, max-size policy
- The max log file count and max log file size can be managed by the LogConfig configuration
root@dintkbwrk01:/var/lib/docker/volumes# docker inspect d10c4f5cc1d87f1fbcb12ed4ee1df3699a47e6c69f08a34cc25f95b7ad772fab
<...>
"LogConfig": {
"Type": "json-file",
"Config": {
"max-file": "5",
"max-size": "50m"
}
},
<...>