Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
4033692d
authored
2013-06-26 18:45:40 -0700
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #85 from Unknwon/master
sync quickstart.
2 parents
b2bfed89
236f28c5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
docs/en/Quickstart.md
docs/en/Quickstart.md
View file @
4033692
...
...
@@ -762,16 +762,29 @@ Beego has a default BeeLogger object that outputs log into stdout, and you can u
beego.SetLogger(*log.Logger)
You can output everything that implemented
`*log.Logger`
, for example, write to file
:
Now Beego supports new way to record your log with automatically log rotate. Use following code in your main function
:
fd,err := os.OpenFile("/var/log/beeapp/beeapp.log", os.O_RDWR|os.O_APPEND, 0644)
filew := beego.NewFileWriter("tmp/log.log", true)
err := filew.StartLogger()
if err != nil {
beego.Critical("openfile beeapp.log:", err)
return
beego.Critical("NewFileWriter err", err)
}
lg := log.New(fd, "", log.Ldate|log.Ltime)
beego.SetLogger(lg)
So Beego records your log into file
`tmp/log.log`
, the second argument indicates whether enable log rotate or not. The rules of rotate as follows:
1.
segment log every 1,000,000 lines.
2.
segment log every 256 MB file size.
3.
segment log daily.
4.
save log file up to 7 days as default.
You cannot segment log over 999 times everyday, the segmented file name with format
`<defined file name>.<date>.<three digits>`
.
You are able to modify rotate rules with following methods, be sure that you call them before
`StartLogger()`
.
-
func (w
*FileLogWriter) SetRotateDaily(daily bool) *
FileLogWriter
-
func (w
*FileLogWriter) SetRotateLines(maxlines int) *
FileLogWriter
-
func (w
*FileLogWriter) SetRotateMaxDays(maxdays int64) *
FileLogWriter
-
func (w
*FileLogWriter) SetRotateSize(maxsize int) *
FileLogWriter
### Different levels of log
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment