ATP Log4Net
A customized logging library for DotNet applications.
Features
- Application Logging
- Event Logging
- Error Logging
Installation
PM> Install-Package QDMLog4Net -Version 1.2.0
Usage
Initialize
using QDMLogger;
Logger logger = new Logger();
logger.init("USER_ID","APPLICATION_NAME", "DATABASE_NAME", "ARANGO_SERVICE_URL", "LOGGER_COLLECTION_NAME","EVENT_COLLECTION_NAME", "LOGGER_NIFI_URL");
Application Logging
Application log levels include the standard set: trace, debug, info, warn, error and fatal.
logger.trace("Entering cheese testing");
logger.debug("Got cheese.");
logger.info("Cheese is Comté.");
logger.warn("Cheese is quite smelly.");
logger.error("Cheese is too ripe!");
logger.fatal("Cheese was breeding ground for listeria.");
Sample Output
{
"TimeStamp": "2022-06-20T00:00:00+05:30",
"LogType": "Application",
"ApplicationName": "clmm",
"UserID": "pxs0362",
"LogLevel": "FATAL",
"FunctionName": "Main",
"FilePath": "C:\\Users\\PanneerSelvam\\MY FOLDERS\\MY PROJECTS\\qdm-log4net\\TestApp\\Program.cs",
"LineNumber": 17,
"LogMessage": "This is new fatal"
}
Event Logging
const string AddPharmacyLocation = "ADD_PH_LOCN";
string eventData = "{ \"PharmacyLocation\":\"Chennai\",\"Pincode\":\"101010\" }";
// Event Logging
logger.Event(AddPharmacyLocation, eventData)
Sample Output
{
"TimeStamp": "2022-06-20T00:00:00+05:30",
"LogType": "Event",
"ApplicationName": "clmm",
"UserID": "pxs0362",
"EventCode": "ADD_PH_LOCN",
"EventName": "Add Pharmacy Location",
"EventFunctionGroup": "Pharmacy",
"EventScreen": "Pharmacy",
"EventData": "{ \"PharmacyLocation\":\"Chennai\",\"Pincode\":\"101010\" }"
}
Error Logging
const string SERVIVE_UNAVAILABLE = "404";
string errorData = "{ \"ErrorData\":\"Service Error}";
// Event Logs
logger.event(SERVIVE_UNAVAILABLE, errorData)
Sample Output
{
"TimeStamp": "2022-06-20T00:00:00+05:30",
"LogType": "Event",
"ApplicationName": "clmm",
"UserID": "pxs0362",
"EventCode": "404",
"ErrorMessage": "Service URL not recognized",
"ErrorDescription": "Server cannot find the requested resources"
}
Configuration (appsettings.json
{
"DBConfig": {
"baseurl": "http://164.52.210.54:8080",
"dbname": "ATP_Metadata_Dev",
"geoLocationDBName": "https://geolocation-db.com/json/",
"loggerCollectionName": "Logger_Config",
"loggerNiFiUrl": "http://101.53.136.60:9999/api/logging"
}
}
Arango DB Details
Name | Value |
---|---|
DB Name | ATP_Metadata_DEV |
Logger Collection Name | Logger_Config |
Event Collection Name | clmm_event_catalog |