https://github.com/alexstocks/log4go
Logging package similar to log4j for the Go programming language
https://github.com/alexstocks/log4go
go golang
Last synced: 3 months ago
JSON representation
Logging package similar to log4j for the Go programming language
- Host: GitHub
- URL: https://github.com/alexstocks/log4go
- Owner: AlexStocks
- License: bsd-2-clause
- Created: 2018-11-02T13:29:18.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T11:46:47.000Z (over 5 years ago)
- Last Synced: 2025-04-23T04:12:25.894Z (3 months ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 1.16 MB
- Stars: 12
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: change_log.md
- License: LICENSE
Awesome Lists containing this project
README
# log4go
---[](https://travis-ci.org/AlexStocks/log4go)
[](https://codecov.io/gh/AlexStocks/log4go)
[](https://pkg.go.dev/github.com/AlexStocks/log4go?tab=doc)
[](https://goreportcard.com/report/github.com/alexstocks/log4go)
Please see http://log4go.googlecode.com/ for more log4go usages. My personal
package (github.com/AlexStocks/goext/log) wrappered log4go functions further
more which provides the most powerful log4go.Installation:
- Run `go get -u -v github.com/AlexStocks/log4go`Usage:
- Add the following import:
``` Go
import l4g "github.com/AlexStocks/log4go"func main() {
defer l4g.Close() // to close l4g.Global
}
```### get logger
#### Global logger
```go
import l4g "github.com/alecthomas/log4go"l4g.Info("hello world")
defer l4g.Close()
```#### NewDefaultLogger
```go
log := l4g.NewDefaultLogger(l4g.INFO)
log.Info("hello world")
defer log.Close()
```#### l4g.Logger
```go
log := make(l4g.Logger)
defer log.Close()
log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter())
log.Info("hello world")
```## output log
```go
l4g.Finest()
l4g.Fine()
l4g.Debug()
l4g.Trace()
l4g.Info()
l4g.Warning()
l4g.Error()
l4g.Critical()
```## UserGuide
### Level
```go
FINEST
FINE
DEBUG
TRACE
INFO
WARNING
ERROR
CRITICAL
```Feature list:
* Output colorful terminal log string by log level
* Output json log
* Add maxbackup choice in examples.xml to delete out of date log file
* Output escape query string safety
* Add filename to every log line
* Create log path if log path does not exist
* Add caller option to let log4go do not output file/function-name/line-number
* Add %P to output process ID
* Rotate log file daily/hourly
* Support json/xml/yml configuration file