Logging Types
App infra provides three different types of logging, each logging type can be configured.
Application Logging
Application Logging is single line simple logging. It can be used by application from anywhere.
The application log includes the time stamp, service name, log level, file name with line no, log tag and log message.
To log application logs, logging API on application context is called.
appCtx.Warn(logTagConfig, "Found multiple config versions: %s hence can not notify listeners", fileVersions)
Sample application log:
[time stamp] [service name] [log level] [file name : line no] [log tag] [log message]
2019/12/31 12:16:52.589 rest-ep [DEBUG] [FileChangeMonitor.go:82] [infra.config.core] Found multiple config versions: 10 hence can not notify listeners
Transaction Logging
Transaction logging is a special type of logging which represents the transaction execution.
A transaction log is generated for the events that happen between the components such as NF, pods, services. The transaction
logs are preserved in the file system residing within the OAM pod to ensure that they are persistent. You can view these logs
through the OAM console. When storing the logs in the file system, you can compress the size of logs by truncating the logs.
Further, you can also define the maximum amount of data that a file must contain which is useful for managing the disk space.
The multiline logs include:
To log transaction logs, logging API on transaction is called.
txn.Debug(LogTagUdm, "Sending request to udm")
Sample Transaction log:
************* TRANSACTION: 00001 *************
TRANSACTION SUCCESS:
Txn Type : MessageTypeExampleCreate(1)
Priority : 100
Session State : Create_Session
Subscriber Id : sub_key:addtcp-123
Session Keys : addtcp-123 (pk) uk1_addtcp-123 (uk) uk2_addtcp-123 (uk) nuk1 (nuk) nuk2 (nuk)
LOG MESSAGES:
2019/12/31 13:05:20.585 [INFO] [service.processor.n7] Message Example_Create decoded
2019/12/31 13:05:20.586 [INFO] [service.processor.n7] Session state is Create_Session
2019/12/31 13:05:20.586 [DEBUG] [infra.transaction.core] Trying to load session
2019/12/31 13:05:20.586 [DEBUG] [infra.session_cache.core] Get session by pk addtcp-123
2019/12/31 13:05:20.586 [DEBUG] [infra.session_cache.core] Record not found by key addtcp-123 in cache, loading from datastore
2019/12/31 13:05:20.586 [DEBUG] [infra.transaction.core] Session start triggered
2019/12/31 13:05:20.586 [DEBUG] [infra.transaction.core] Queuing new transaction for processing
2019/12/31 13:05:20.586 [DEBUG] [service.udm_query.n7] Sending request to udm
2019/12/31 13:05:20.592 [DEBUG] [service.udm_query.n7] Received response from udm response:"2"
2019/12/31 13:05:20.592 [DEBUG] [infra.transaction.core] Last stage ( init_done ) -> Next stage ( udm_done )
2019/12/31 13:05:20.592 [DEBUG] [service.udm_query.n7] Sending udp request
2019/12/31 13:05:20.595 [INFO] [service.udm_query.n7] Received udp response response:"Success"
2019/12/31 13:05:20.595 [DEBUG] [infra.transaction.core] Last stage ( udm_done ) -> Next stage ( udp_done )
2019/12/31 13:05:20.595 [DEBUG] [service.udm_query.n7] Sending Tcp request
2019/12/31 13:05:20.603 [INFO] [service.udm_query.n7] Received tcp response response:"Success"
2019/12/31 13:05:20.603 [DEBUG] [infra.transaction.core] Last stage ( udp_done ) -> Next stage ( finished )
2019/12/31 13:05:20.603 [INFO] [service.processor.n7] Process end
2019/12/31 13:05:20.603 [DEBUG] [infra.transaction.core] Creating session
2019/12/31 13:05:20.603 [DEBUG] [infra.session_cache.core] Save session with key addtcp-123 in cache
***********************************************
Transaction Logs Additional Settings
Transaction logging have following two additional settings which can be optionally enabled.
-
Message: Using CLI enable messages in transaction logging can be enabled, "logging transaction message enable". Incoming request
and outgoing response messages associated with the transaction in transaction logs can also be enabled.
Transaction Log received from Instance: example.rest_ep.cluster1.example-data.1
************* TRANSACTION: 00046 *************
TRANSACTION SUCCESS:
Txn Type : MessageTypeExampleDelete(5)
Priority : 1
Session State : No_Session
INCOMING REQUEST:
Timestamp: 2020/03/23 06:23:27.146
Message: Example Delete Request
Description: Transaction REST Req Message
Source: 192.168.2.168:9001//session/123
Destination: example.rest_ep.cluster1.example-data.1
PAYLOAD:
Key: 123
OUTGOING RESPONSE:
Timestamp: 2020/03/23 06:23:27.146
Message: Example Delete Response
Description: Transaction REST Rsp Message
Source: example.rest_ep.cluster1.example-data.1
Destination: 192.168.2.168:9001//session/123
PAYLOAD:
PduSessionId: 5
LOG MESSAGES:
2020/03/23 06:23:27.146 [INFO] [rest_ep.app.n7] Process end
2020/03/23 06:23:27.146 [INFO] [rest_ep.app.n7] Prepare success response
2020/03/23 06:23:27.146 [INFO] [rest_ep.app.n7] Response: response:"Success" delete_rsp:<pduSessionId:5 > udp_rsp:<udpSessionId:5555 >
-
Duplicate: Using CLI duplicate in transaction logging can be enabled"logging transaction duplicate enable". Transaction logs
duplicated in application context logs can also be enabled.
Monitor Subscriber Logging
This logging helps to control the logging level of transaction logs when monitor subscriber CLI is enabled. Monitor Subscriber
CLI can be used to capture the transaction logs for a given supi. With Monitor Subscriber Logger we can control the logging
level specifically for the subscriber for which monitor subscriber CLI is triggerred.
This logging is helpful in where transaction logs are set to error by default and capturing the debug level transaction logs
for certain modules specific subscriber is useful. This can be achieved using the below two steps:
-
Enable the Monitor Subscriber logger at info level using command: Example: logging name infra.config.core level monitor-subscriber
debug.
-
Enable the monitor subscriber for given subscriber using the following sample command:
monitor subscriber supi imsi-123456789 transaction-logs yes
Sample Monitor Subscriber Log
[cluster1/data] example# monitor subscriber supi imsi-123456789 transaction-logs yes
supi: imsi-123456789
captureDuraiton: 300
enableInternalMsg: false
enableTxnLog: true
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 242 100 100 100 142 14285 20285 --:--:-- --:--:-- --:--:-- 34571
Command: --header Content-type:application/json --request POST --data {"commandname":"mon_sub","parameters":{"supi":"imsi-123456789",
"duration":300,"enableTxnLog":true,"enableInternalMsg":false,"action":"start"}} http://oam-pod:8879/commands
Result start mon_sub, fileName ->monsublogs/imsi-123456789_WithTxnLogs_TS_2020-03-23T08:16:19.806104824.txt
Starting to tail the monsub messages from file: monsublogs/imsi-123456789_WithTxnLogs_TS_2020-03-23T08:16:19.806104824.txt
Transaction Log received from Instance: example.rest_ep.cluster1.example-data.1
************* TRANSACTION: 00038 *************
TRANSACTION SUCCESS:
Txn Type : MessageTypeExampleRestQuery(6)
Priority : 1
Session State : No_Session
LOG MESSAGES:
2020/03/23 06:23:27.093 [INFO] [rest_ep.app.n7] Message Sample_Rest_Query decoded
2020/03/23 06:23:27.093 [INFO] [rest_ep.app.n7] Process init
2020/03/23 06:23:27.093 [INFO] [rest_ep.app.n7] Process continue
2020/03/23 06:23:27.093 [INFO] [infra.transaction.core] Calling RPC Udm on host Udm_v1 proc-name Udm proc-method: Register
2020/03/23 06:23:27.094 [INFO] [rest_ep.app.n7] Process end
2020/03/23 06:23:27.094 [INFO] [rest_ep.app.n7] Prepare success response
2020/03/23 06:23:27.094 [INFO] [rest_ep.app.n7] default Response: response:"123" rest_rsp:<restSessionId:5678 >
***********************************************
Trace Logging
Similar to transaction logging, tracing is also special type logging. This logs are appended in traces. Refer tracing section
to understand more about trac logging.
To log trace logs, logging trace API on transaction is called:
txn.DebugTrace(LogTagUdm, "Sending request to udm")
To differentiate trace APIs with transaction APIs, all trace logging apis are suffixed with Trace word.
txn.ErrorTrace() txn.WarnTrace() txn.InfoTrace() txn.DebugTrace() txn.TraceTrace()