---
sidebar_position: 3
---

# Log

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

Logs the given message as a raw message.

Go: `LogPrint(ctx context.Context, message string)`<br/>
JS: `LogPrint(message: string)`

### LogPrintf

Logs the given message as a raw message.

Go: `LogPrintf(ctx context.Context, format string, args ...interface{})`<br/>

### LogTrace

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

Go: `LogTrace(ctx context.Context, message string)`<br/>
JS: `LogTrace(message: string)`

### LogTracef

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

Go: `LogTracef(ctx context.Context, format string, args ...interface{})`<br/>

### LogDebug

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

Go: `LogDebug(ctx context.Context, message string)`<br/>
JS: `LogDebug(message: string)`

### LogDebugf

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

Go: `LogDebugf(ctx context.Context, format string, args ...interface{})`<br/>

### LogInfo

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

Go: `LogInfo(ctx context.Context, message string)`<br/>
JS: `LogInfo(message: string)`

### LogInfof

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

Go: `LogInfof(ctx context.Context, format string, args ...interface{})`<br/>

### LogWarning

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

Go: `LogWarning(ctx context.Context, message string)`<br/>
JS: `LogWarning(message: string)`

### LogWarningf

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

Go: `LogWarningf(ctx context.Context, format string, args ...interface{})`<br/>

### LogError

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

Go: `LogError(ctx context.Context, message string)`<br/>
JS: `LogError(message: string)`

### LogErrorf

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

Go: `LogErrorf(ctx context.Context, format string, args ...interface{})`<br/>

### LogFatal

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

Go: `LogFatal(ctx context.Context, message string)`<br/>
JS: `LogFatal(message: string)`

### LogFatalf

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

Go: `LogFatalf(ctx context.Context, format string, args ...interface{})`<br/>

### LogSetLogLevel

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     |

Go: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`<br/>
JS: `LogSetLogLevel(level: number)`

## Using a Custom Logger

A custom logger may be used by providing it using the [Logger](../options.mdx#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)
}
```
