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.
LogPrintfโ
Go Signature: LogPrintf(ctx context.Context, format string, args ...interface{})
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.
LogTracefโ
Go Signature: LogTracef(ctx context.Context, format string, args ...interface{})
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.
LogDebugfโ
Go Signature: LogDebugf(ctx context.Context, format string, args ...interface{})
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.
LogInfofโ
Go Signature: LogInfof(ctx context.Context, format string, args ...interface{})
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.
LogWarningfโ
Go Signature: LogWarningf(ctx context.Context, format string, args ...interface{})
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.
LogErrorfโ
Go Signature: LogErrorf(ctx context.Context, format string, args ...interface{})
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.
LogFatalfโ
Go Signature: LogFatalf(ctx context.Context, format string, args ...interface{})
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
application option. The only requirement is that the logger implements the logger.Logger interface
defined in github.com/wailsapp/wails/v2/pkg/logger:
type Logger interface {
    Print(message string)
    Trace(message string)
    Debug(message string)
    Info(message string)
    Warning(message string)
    Error(message string)
    Fatal(message string)
}