Skip to content

@tauri-apps/plugin-log

Configure the Tauri application log system, and access the JavaScript-side log functions.

function attachConsole(): Promise<UnlistenFn>;

Defined in: plugins/log/guest-js/index.ts:321

Attaches a listener that writes log entries to the console as they come in.

import { attachConsole } from '@tauri-apps/plugin-log';
const detach = await attachConsole();
// detach the listener later
detach();

Promise<UnlistenFn>

a promise resolving to a function to cancel the listener.

2.0.0


function attachLogger(fn: LoggerFn): Promise<UnlistenFn>;

Defined in: plugins/log/guest-js/index.ts:289

Attaches a listener for the log, and calls the passed function for each log entry.

import { attachLogger } from '@tauri-apps/plugin-log';
const detach = await attachLogger(({ level, message }) => {
console.log(`[${level}] ${message}`);
});
// detach the listener later
detach();
Parameter Type Description
fn LoggerFn a function to call for every log entry emitted by the Rust side.

Promise<UnlistenFn>

a promise resolving to a function to cancel the listener.

2.0.0


function debug(message: string, options?: LogOptions): Promise<void>;

Defined in: plugins/log/guest-js/index.ts:233

Logs a message at the debug level.

import { debug } from '@tauri-apps/plugin-log';
const pos = { x: 3.234, y: -1.223 };
debug(`New position: x: {pos.x}, y: {pos.y}`);
Parameter Type Description
message string the message to log.
options? LogOptions additional metadata (file, line, key-values) to attach to the log entry.

Promise<void>

2.0.0


function error(message: string, options?: LogOptions): Promise<void>;

Defined in: plugins/log/guest-js/index.ts:164

Logs a message at the error level.

import { error } from '@tauri-apps/plugin-log';
const err_info = "No connection";
const port = 22;
error(`Error: ${err_info} on port ${port}`);
Parameter Type Description
message string the message to log.
options? LogOptions additional metadata (file, line, key-values) to attach to the log entry.

Promise<void>

2.0.0


function info(message: string, options?: LogOptions): Promise<void>;

Defined in: plugins/log/guest-js/index.ts:210

Logs a message at the info level.

import { info } from '@tauri-apps/plugin-log';
const conn_info = { port: 40, speed: 3.20 };
info(`Connected to port {conn_info.port} at {conn_info.speed} Mb/s`);
Parameter Type Description
message string the message to log.
options? LogOptions additional metadata (file, line, key-values) to attach to the log entry.

Promise<void>

2.0.0


function trace(message: string, options?: LogOptions): Promise<void>;

Defined in: plugins/log/guest-js/index.ts:256

Logs a message at the trace level.

import { trace } from '@tauri-apps/plugin-log';
let pos = { x: 3.234, y: -1.223 };
trace(`Position is: x: {pos.x}, y: {pos.y}`);
Parameter Type Description
message string the message to log.
options? LogOptions additional metadata (file, line, key-values) to attach to the log entry.

Promise<void>

2.0.0


function warn(message: string, options?: LogOptions): Promise<void>;

Defined in: plugins/log/guest-js/index.ts:187

Logs a message at the warn level.

import { warn } from '@tauri-apps/plugin-log';
const warn_description = "Invalid Input";
warn(`Warning! {warn_description}!`);
Parameter Type Description
message string the message to log.
options? LogOptions additional metadata (file, line, key-values) to attach to the log entry.

Promise<void>

2.0.0

Defined in: plugins/log/guest-js/index.ts:29

The verbosity level of a log entry, matching the levels of the Rust log crate.

Enumeration Member Value Description Defined in
Debug 2 The “debug” level. Designates lower priority information. plugins/log/guest-js/index.ts:41
Error 5 The “error” level. Designates very serious errors. plugins/log/guest-js/index.ts:59
Info 3 The “info” level. Designates useful information. plugins/log/guest-js/index.ts:47
Trace 1 The “trace” level. Designates very low priority, often extremely verbose, information. plugins/log/guest-js/index.ts:35
Warn 4 The “warn” level. Designates hazardous situations. plugins/log/guest-js/index.ts:53

Defined in: plugins/log/guest-js/index.ts:17

Options to associate extra metadata with a log entry.

Property Type Description Defined in
file? string The name of the file that emitted the log entry. Included in the log record’s target when set. plugins/log/guest-js/index.ts:19
keyValues? Record<string, string | undefined> Additional structured key-value pairs to attach to the log entry. plugins/log/guest-js/index.ts:23
line? number The line number in LogOptions.file that emitted the log entry. plugins/log/guest-js/index.ts:21

© 2026 Tauri Contributors. CC-BY / MIT