---
sidebar_position: 3
---

# Log

## Overview

The Wails runtime provides a logging mechanism that may be called from Go or Javascript. Like most
loggers, there are a number of log levels:

  - Trace
  - Debug
  - Info
  - Warning
  - Error
  - Fatal

The logger will output any log message at the current, or higher, log level. Example: The `Debug` log
level will output all messages except `Trace` messages.

### LogPrint

Go Signature: `LogPrint(ctx context.Context, message string)`

JS Signature: `LogPrint(message: string)`

Logs the given message as a raw message.

### LogTrace

Go Signature: `LogTrace(ctx context.Context, message string)`

JS Signature: `LogTrace(message: string)`

Logs the given message at the `Trace` log level.

### LogDebug

Go Signature: `LogDebug(ctx context.Context, message string)`

JS Signature: `LogDebug(message: string)`

Logs the given message at the `Debug` log level.


### LogInfo

Go Signature: `LogInfo(ctx context.Context, message string)`

JS Signature: `LogInfo(message: string)`

Logs the given message at the `Info` log level.


### LogWarning

Go Signature: `LogWarning(ctx context.Context, message string)`

JS Signature: `LogWarning(message: string)`

Logs the given message at the `Warning` log level.


### LogError

Go Signature: `LogError(ctx context.Context, message string)`

JS Signature: `LogError(message: string)`

Logs the given message at the `Error` log level.


### LogFatal
Go Signature: `LogFatal(ctx context.Context, message string)`

JS Signature: `LogFatal(message: string)`

Logs the given message at the `Fatal` log level.

### LogSetLogLevel

Go Signature: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`

JS Signature: `LogSetLogLevel(level: number)`

Sets the log level. In Javascript, the number relates to the following log levels:

| Value | Log Level |
| ----- | --------- |
| 1     | Trace     |
| 2     | Debug     |
| 3     | Info      |
| 4     | Warning   |
| 5     | Error     |

## Using a Custom Logger

A custom logger may be used by providing it using the [Logger](/docs/reference/options#logger)
application option. The only requirement is that the logger implements the `logger.Logger` interface
defined in `github.com/wailsapp/wails/v2/pkg/logger`:

```go title="logger.go"
type Logger interface {
	Print(message string)
	Trace(message string)
	Debug(message string)
	Info(message string)
	Warning(message string)
	Error(message string)
	Fatal(message string)
}
```

