Questions tagged [logrus]

38 questions
34
votes
2 answers

Golang logrus - how to do a centralized configuration?

I am using logrus in a Go app. I believe this question is applicable to any other logging package (which doesn't offer external file based configuration) as well. logrus provides functions to setup various configuration, e.g. SetOutput, SetLevel…
Dipen Bhikadya
  • 3,318
  • 3
  • 21
  • 19
6
votes
1 answer

aws-sdk-go-v2 custom logger

With v1 of the SDK i could use logrus for my custom logger, like: Logger: aws.LoggerFunc(func(args ...interface{}) { log.WithField("process", "s3").Debug(args...) }), This has changed with sdk v2,…
Rygo
  • 159
  • 1
  • 8
3
votes
0 answers

How to create Logger in RESTFUL API for best practice?

I have made RESTFUL API using GO and existing Module like ECHO, GORM, WIRE, LOGRUS, VIPER. But i dont know best practice how to create Beautiful Logger for every activity when someone Hit or Consume my endpoint URL in all HTTP Method Request…
ramadoiranedar
  • 137
  • 2
  • 7
3
votes
1 answer

Daily Log Rotation for Golang Project

I am using logrus package for logging. Want to rotate the logs on daily basis. I have explored options like lumberjack and logrotate(8) But lumberjack provides log rotation based on the size of the log file. Not sure if there is any way to make it…
Sumit Bopche
  • 658
  • 5
  • 9
2
votes
1 answer

Asserting That Code Should Panic With Logrus Error

When using logrus, how do you assert for panic using an assertion library like testify? Take the following code for an example: var mylogger = logrus.WithContext("MyLogger") func LoadPreparedStatements() { db := psql.PsqlClient() var err…
PressingOnAlways
  • 11,948
  • 6
  • 32
  • 59
2
votes
1 answer

Logrus: Set log level based on package name through configuration

In the Java world it's relatively common to create one logger per package/class- something like: final static Logger logger = Logger.getLogger("foo.bar.baz"); This means that in configuration we can set different log levels for different…
d80tb7
  • 863
  • 2
  • 9
  • 20
2
votes
1 answer

Golang Logrus Enable Opentelemetry Trace ID and Span ID in all Application Logs

I am trying to enable Trace ID and Span ID for every application log. I am using opentelemtry APIs to inject and logrus labrary for logging. Below is an example code where i am able to enable trace/span entried to all logs but the trace and span id…
Arjun Kanti
  • 101
  • 2
  • 4
  • 12
2
votes
3 answers

How to re-create log file automatically in logrus/lumberjack on macOS

I use logrus and lumberjack for log file on macOS. logger := &lumberjack.Logger{ // Log path Filename: filepath.Join(logFolder, "xxx.log"), // Log size MB MaxSize: 10, // Backup count MaxBackups: 3, // expire days //…
Jerry YY Rain
  • 4,134
  • 7
  • 35
  • 52
2
votes
0 answers

Log HTTP Endpoint and Payload GRPC

I want to log my payload using Logrus on grpc. I've made it using grpc_middleware but the log format is not what I want. I'm using *logrus.Logger as param for logrus.NewEntry() the code is just like this: logrusEntry := logrus.NewEntry(logger) …
Enryu
  • 91
  • 11
2
votes
0 answers

Make fields of JSON logs from Docker container available in GCP Logs via google-fluentd

First let me explain the setup/system: I have a virtual Ubuntu 18.04 machine running via GCP Compute Engine. I have followed the GCP documentation and have installed the structured logging agent via apt-get. On this machine I have a golang…
datosh
  • 498
  • 7
  • 20
2
votes
1 answer

Is it possible to swap 'msg' for 'message' with logrus logging

So when using Logrus I need the logging output to have the message key instead of msg key, but when I use the code below I get both, but msg is empty, how can I configure logrus to use 'message' instead of…
M_K
  • 3,247
  • 6
  • 30
  • 47
2
votes
1 answer

Logrus escaping ampersand character

I'm using Logrus and I have encountered an issue with displaying & character in its logs: logger.WithFields(logrus.Fields{ "value": "value&value", }).Info("GET") This prints value\u0026value i.e. hex value of & instead of & itself Anyone…
mangusta
  • 3,470
  • 5
  • 24
  • 47
2
votes
2 answers

Passing context.Context to all relevant methods, golang

I read all the decisions about dropping the ThreadLocal and I can relate. Seems like passing around the request.Context() that is of type context.Context gives the ability to manage scoped services. I am using logrus for logging and want to log a…
Mortalus
  • 10,574
  • 11
  • 67
  • 117
1
vote
1 answer

How to custom Go Gin logger format?

How to customise the logger format of Gin api app ? I tried to do it with the logrus package, but my problem is that : when I intentionally made 404 or 400 error, there's no error message printing in the console. Also I want the logger to display…
Jackk-Doe
  • 109
  • 7
1
vote
1 answer

Add correlation Id for logs with logrus:Golang

I'm trying to find a way to add a correlation/request id for logs in our project to make it easier to navigate through them and debug when some issues occur. I found this article. From the example there, there is a middleware to add the…
indee423
  • 121
  • 1
  • 11
1
2 3