---
# System prepended metadata

title: Beego Logs Module

---

# Beego Logs Module

### Using Logs module
```go=0
import "github.com/beego/beego/v2/core/logs"

// add config option to main.go file or log initialization specific file
// by default access logs are disabled in 'prod'
web.BConfig.Log.AccessLogs = true

// by default logs will be printed in console
```

### Saving logs to file
Log canbe saved to specified file using Beego Logs module. Here log is saved in project.log file located in logs folder. 'Maxdays' represents how long logs will be kept.

Other parameters than can be set are-
* maxlines: Maximum lines for each log file, 1000000 by default.
* maxsize: Maximum size of each log file, 1 << 28 or 256M by default.
* daily: If log rotates by day, true by default.
* maxdays: Maximum number of days log files will be kept, 7 by default.
* rotate: Enable logrotate or not, true by default.
* level: Log level, Trace by default.
* perm: Log file permission
* separate: Log file will separate to test.error.log/test.debug.log as the log level set in the json array [in case of multifile only]

```go=0
// setting up project.log file to rotate daily and 1 day maxday
	fileLoggingErr := logs.SetLogger(logs.AdapterFile, `{"filename":"./logs/project.log", "daily":true, "maxdays":1, "color":true}`)
	if fileLoggingErr != nil{
		 log.Println("Error with file logging")
		 panic(fileLoggingErr)
	}
    
// logging to multiple files
        multiLoggingErr := logs.SetLogger(logs.AdapterMultiFile, `{"filename":"./logs/test.log","separate":["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"]}`)
	if multiLoggingErr != nil {
		panic(multiLoggingErr)
	}
```

### Log to web interface
Feature not available in Beego Framework. It only works for predefined adapaters, these are:
1. Console
2. File
3. Net and
4. SMTP

### Links:
1. [Beego Logs module official documentation](https://beego.me/docs/module/logs.md)
2. [Configuration documentation](https://beego.me/docs/mvc/controller/config.md)