@tauri-apps/plugin-log
Configure the Tauri application log system, and access the JavaScript-side log functions.
Enumerations
Section titled “Enumerations”LogLevel
Section titled “LogLevel”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L29
The verbosity level of a log entry, matching the levels of the Rust log crate.
Enumeration Members
Section titled “Enumeration Members”Debug: 2;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L41
The “debug” level.
Designates lower priority information.
Error: 5;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L59
The “error” level.
Designates very serious errors.
Info: 3;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L47
The “info” level.
Designates useful information.
Trace: 1;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L35
The “trace” level.
Designates very low priority, often extremely verbose, information.
Warn: 4;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L53
The “warn” level.
Designates hazardous situations.
Interfaces
Section titled “Interfaces”LogOptions
Section titled “LogOptions”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L17
Options to associate extra metadata with a log entry.
Properties
Section titled “Properties”| 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. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L19 |
keyValues? |
Record<string, string | undefined> |
Additional structured key-value pairs to attach to the log entry. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L23 |
line? |
number |
The line number in LogOptions.file that emitted the log entry. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L21 |
Functions
Section titled “Functions”attachConsole()
Section titled “attachConsole()”function attachConsole(): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L321
Attaches a listener that writes log entries to the console as they come in.
Returns
Section titled “Returns”Promise<UnlistenFn>
a promise resolving to a function to cancel the listener.
Example
Section titled “Example”import { attachConsole } from '@tauri-apps/plugin-log';
const detach = await attachConsole();
// detach the listener laterdetach();2.0.0
attachLogger()
Section titled “attachLogger()”function attachLogger(fn): Promise<UnlistenFn>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L289
Attaches a listener for the log, and calls the passed function for each log entry.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fn |
LoggerFn |
a function to call for every log entry emitted by the Rust side. |
Returns
Section titled “Returns”Promise<UnlistenFn>
a promise resolving to a function to cancel the listener.
Example
Section titled “Example”import { attachLogger } from '@tauri-apps/plugin-log';
const detach = await attachLogger(({ level, message }) => { console.log(`[${level}] ${message}`);});
// detach the listener laterdetach();2.0.0
debug()
Section titled “debug()”function debug(message, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L233
Logs a message at the debug level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
the message to log. |
options? |
LogOptions |
additional metadata (file, line, key-values) to attach to the log entry. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { debug } from '@tauri-apps/plugin-log';
const pos = { x: 3.234, y: -1.223 };
debug(`New position: x: {pos.x}, y: {pos.y}`);2.0.0
error()
Section titled “error()”function error(message, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L164
Logs a message at the error level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
the message to log. |
options? |
LogOptions |
additional metadata (file, line, key-values) to attach to the log entry. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { error } from '@tauri-apps/plugin-log';
const err_info = "No connection";const port = 22;
error(`Error: ${err_info} on port ${port}`);2.0.0
info()
Section titled “info()”function info(message, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L210
Logs a message at the info level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
the message to log. |
options? |
LogOptions |
additional metadata (file, line, key-values) to attach to the log entry. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”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`);2.0.0
trace()
Section titled “trace()”function trace(message, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L256
Logs a message at the trace level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
the message to log. |
options? |
LogOptions |
additional metadata (file, line, key-values) to attach to the log entry. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { trace } from '@tauri-apps/plugin-log';
let pos = { x: 3.234, y: -1.223 };
trace(`Position is: x: {pos.x}, y: {pos.y}`);2.0.0
warn()
Section titled “warn()”function warn(message, options?): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/log/guest-js/index.ts#L187
Logs a message at the warn level.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
message |
string |
the message to log. |
options? |
LogOptions |
additional metadata (file, line, key-values) to attach to the log entry. |
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { warn } from '@tauri-apps/plugin-log';
const warn_description = "Invalid Input";
warn(`Warning! {warn_description}!`);2.0.0
© 2026 Tauri Contributors. CC-BY / MIT