Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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 (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T11:46:47.000Z (almost 5 years ago)
- Last Synced: 2024-11-01T19:52:36.401Z (3 months ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 1.16 MB
- Stars: 12
- Watchers: 3
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: change_log.md
- License: LICENSE
Awesome Lists containing this project
README
# log4go
---[![Build Status](https://travis-ci.org/AlexStocks/log4go.svg?branch=master)](https://travis-ci.org/AlexStocks/log4go)
[![codecov](https://codecov.io/gh/AlexStocks/log4go/branch/master/graph/badge.svg)](https://codecov.io/gh/AlexStocks/log4go)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/AlexStocks/log4go?tab=doc)
[![Go Report Card](https://goreportcard.com/badge/github.com/alexstocks/log4go)](https://goreportcard.com/report/github.com/alexstocks/log4go)
![license](https://img.shields.io/badge/license-Apache--2.0-green.svg)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