Skip to content

Log Configuration

Acquiring the Logger

For standard uni-app:

import { logger } from '@/uni_modules/GC-UniPlugin';

For uni mini-programs:

import { logger } from '@/uni_modules/GC-JSPlugin';

For uni mini-programs, Log initialization is performed by the host App. Only runtime APIs such as logging() are called.

Log Initialization Configuration

logger.setConfig({
    enableLinkRumData: true,
    enableCustomLog: true,
    discardStrategy: 'discardOldest'
});
Parameter Type Required Description
sampleRate number No Sampling rate, range [0,1], default 1
enableLinkRumData boolean No Whether to link with RUM data
enableCustomLog boolean No Whether to enable custom logs
discardStrategy string No Log discard strategy: discard, discardOldest
logLevelFilters array No Log level filter: info, debug, warning, error, critical, ok
globalContext object No Custom global context
logCacheLimitCount number No Maximum number of logs cached locally, default 5000

Logger Logging

logger.logging({
    content: 'Log content',
    status: 'info',
    property: {
        order_id: 'order-1001'
    }
});

API - logging

Field Type Required Description
content string Yes Log content, can be a JSON string
status string/number No Log level, default determined by the platform SDK
property object No Event context

Log Levels

String Meaning
info Informational
debug Debug
warning Warning
error Error
critical Critical
ok OK

Feedback

Is this page helpful?