@todo fix me!
v1.0.1
  • Get Started
  • Templates
  • GitHub
  • Overview
  • B24Hook
  • Methods
  • callMethod
  • callFastListMethod
  • fetchListMethod
  • callBatch
  • callBatchByChunk
  • getTargetOrigin
  • getTargetOriginWithPath
  • getLogger
  • setLogger
  • destroy
  • getHttpClient
  • offClientSideWarning
  • Getters
  • auth
  • isInit
  • b24ui
  • b24icons
v1.0.1
  • Docs
  • Frame
  • Hook
  • OAuth
  • Templates

B24Hook.setLogger()

Use this method to configure detailed logging during development.
B24Hook
TypeB24

@todo

The B24Hook object is intended exclusively for use on the server.
  • A webhook contains a secret access key, which MUST NOT be used in client-side code (browser, mobile app).
  • For the client side, use B24Frame.

Usage

setLogger(logger: LoggerBrowser): void

Sets a custom LoggerBrowser instance for B24Hook.

Use this method to configure detailed logging during development.

The logger will be automatically passed to the HTTP client for end-to-end logging of requests.

Examples

Use simple LoggerBrowser

import { B24Hook, LoggerBrowser, LoggerType } from '@bitrix24/b24jssdk'

// Define the dev mode
const devMode = typeof import.meta !== 'undefined' && (import.meta.env?.DEV || import.meta.dev)
const loggerForDebugB24 = LoggerBrowser.build('MyApp:DebugB24', devMode)

const $b24 = B24Hook.fromWebhookUrl('https://your_domain.bitrix24.com/rest/1/xxxx/')
$b24.setLogger(loggerForDebugB24)

Fine-tuning LoggerBrowser

Example of fine-tuning a LoggerBrowser instance for B24Hook

import { B24Hook, LoggerBrowser, LoggerType } from '@bitrix24/b24jssdk'

const loggerForDebugB24 = LoggerBrowser.build('MyApp:DebugB24')
loggerForDebugB24.setConfig({
  [LoggerType.desktop]: false,
  [LoggerType.log]: true,
  [LoggerType.info]: true,
  [LoggerType.warn]: true,
  [LoggerType.error]: true,
  [LoggerType.trace]: true
})

const $b24 = B24Hook.fromWebhookUrl('https://your_domain.bitrix24.com/rest/1/xxxx/')
$b24.setLogger(loggerForDebugB24)

Next Steps

Core API methods:

  • callMethod() — Call any REST API method
  • callBatch() — Batch execution of up to 50 commands

Working with lists:

  • callFastListMethod() — Automatic retrieval of all list pages
  • fetchListMethod() — Incremental loading of large lists via generator

Advanced scenarios:

  • callBatchByChunk() — Batch execution of any number of commands with automatic chunking

getLogger

Returns a LoggerInterface from a B24Hook instance.

destroy

Destructor. Used to destroy or clean up resources. Works only in server environment.

On this page

  • Usage
  • Examples
    • Use simple LoggerBrowser
    • Fine-tuning LoggerBrowser
  • Next Steps
Releases
Published under MIT License.

Copyright © 2024-present Bitrix24