System Logging Support Per SUPI

Feature Summary and Revision History

Table 1. Revision History

Revision Details

Release

First introduced.

Pre-2020.02.0

Feature Description

Application infracture provide common way to log the log messages across applications. Each log has timestamp, log message, log level and log tag.

Log tag is made up of module name, component name and interface name. It is used as filter to enable/disable specific type of log messages. Log tag needs to be pre-created and is supposed to be pass while logging.

Creating log tag

common.LogTagN7RestEp = appCtx.RegisterLogTag("rest_ep", "app", "n7")

Log a message

appCtx.Info(common.LogTagN7RestEp, "Starting rest-ep app")

Log Level

App infra provides 6 log levels, which can be used as filter along with log tag to enable/disable specific logs. Each level represents the level of importance of log message, which can be used while troubleshooting.

Log Level

Usage

Error

Error is used when there is incorrectness which can lead to serious issues.

Warn

Warn can used to notify something serious is about to happen if it continous like this and not attended.

Info

Info can used for normal expected behavior like app started, stopped, etc.

Debug

Debug can used to provide more information which is require to debug problems.

Trace

Trace can used to provide very detailed information. It can also be used in monitor routines where same debug log is keep coming periodically.

Off

Meaning no loggin informatin, this can be configured in CLI to turn off/turn on logging.

Log Level Order

Every time app infra is logging any log message, it matches the log level and log tag with configured log setting before logging.

Log Level (order)

Usage

Error (0)

Matches error logs.

Warn (1)

Matches warn and error logs.

Info (2)

Matches info, warn and error logs.

Debug (3)

Matches debug, info, warn and error logs.

Trace (4)

Matches trace, debug, info, warn and error logs.

Off (5)

Matches no log to disable errors.

Logging Types

App infra provides three different types of logging, each logging type can be configured.

  • Application logging

  • Transaction logging

  • Monitor Subscriber Logging

  • Trace logging

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:

  • Transaction type, priority and status

  • Session state

  • Session and subscriber IDs (if available)

  • Execution logs

    • Each execution log include timestamp, log level, log tag and log message

    • The log level and log tag can be used as filter to enable/disable specific logs

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.

  1. 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 >
    
  2. 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:

  1. Enable the Monitor Subscriber logger at info level using command: Example: logging name infra.config.core level monitor-subscriber debug.

  2. 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()

Configuration Support for Persistent Transaction Logs

This section describes how to configure support for the persistent transaction logging.

Configuration of persistent transaction logs involves the following steps:

  • Configuring the persistent transaction logs

  • Viewing the transaction logs

Configuring the Persistent Transaction Logs

This section describes how to configure the persistent transaction log parameters.

The transaction logs are saved in the transaction log file which reside in the transaction logs directory of OAM pod.

config 
  logging 
    transaction 
      persist [ disable | enable ] 
      max-file-size max_filesize 
      max-rotation max_rotation 
      end 

NOTES:

  • logging – Enters the logging configuration mode.

  • transaction– Enters the transaction log configuration mode.

  • persist [ disable | enable ]– Configures the ability to write the transaction logs to the transaction log file.

  • max-file-size max_filesize – Specifies the maximum size (in MB) of the transaction logs that must be preserved in the file. The default size is 50 MB. The accepted range is 1–10000 MB.

  • max-rotation max_rotation – Specifies the maximum number of files that must be stored in the folder. After the specified number is reached, the files are rotated, which means that the oldest file is deleted and the latest log file is added to the folder. For example, if the folder has files a1.txt–a.10.txt and when the a.11.txt is added, then a1.txt is deleted. The default number is 10. The accepted range is 2–1000.

Viewing the Transaction Logs

This section describes how to view the transaction logs that are stored on the OAM pod.

To view the persistent transaction logs, use the following configuration through the SMF Ops Center:

transaction file dump filename file_path 

You can use the transaction log list command to view the list of log files and their paths.

The following is a sample output of the transaction logs:

RELEASE_NAMESPACE: 'example-data'
Dumping file 'transactionlogs/transaction.log.20200907033433.4.gz'
InstanceInfo: example.example-rest-ep.cluster1.example-data.1
TimeStamp: 2020-09-09 00:25:18.379439773 +0000 UTC
************* TRANSACTION: 01371 *************
TRANSACTION SUCCESS:
    Txn Type             : MessageTypeExampleCreate(1)
    Priority             : 1
    Session Namespace    : none(0)
LOG MESSAGES:
    2020/09/09 00:25:18.339 [INFO] [rest_ep.app.n7] Message Example_Create decod
ed
    2020/09/09 00:25:18.339 [INFO] [rest_ep.app.n7] Process init
    2020/09/09 00:25:18.339 [DEBUG] [rest_ep.app.n7] Config from GetConfig is Ve
rsion: 783da2fc038c6bc961a95e2bf3dd6d93f282e36b30e0362698a1de369a2fd15c Services
: [Name: restServer Type: Rest Endpoint: sbi Name: tcpServer Type: Tcp Endpoint:
 tcp-protocol Name: udpServer Type: Udp Endpoint: udp-protocol]
    2020/09/09 00:25:18.339 [INFO] [rest_ep.app.n7] Process continue
    2020/09/09 00:25:18.339 [DEBUG] [rest_ep.app.n7] DerivedConfig from GetConfi
g is DerivedNameToBeTested_cb3383b95927a434d42cd9d5687ccf1b13e2de4b2faf4543287a3
4afb32518fe
    2020/09/09 00:25:18.339 [DEBUG] [rest_ep.udp.n5] Sending message Example_Cre
ate to example-service
    2020/09/09 00:25:18.342 [INFO] [infra.transaction.core] Calling RPC example-
service_ipc_stream on host example-service_1 proc-name example-service_ipc_strea