You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/12/23 05:43:55 UTC

[GitHub] [pulsar-client-go] JoseFMP opened a new issue #430: Disable logger

JoseFMP opened a new issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430


   In general, is there any way to disable the logger or use an alternative logger? I can see in the client configuration there is a field `Logger` but I cannot find any example on how to disable or reconfigure it. If I set it to `nil` all the logs are dumped in my console. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] merlimat commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
merlimat commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-749952251


   We're using Logrus (https://github.com/sirupsen/logrus), so you can use that API to configure or disable the loggeing


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] JoseFMP commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
JoseFMP commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-755921243


   @yuanweikang2020  Thank you!
   
   Wondering how to do it not globally for all `logrus` loggers running in a process.
   
   Use case: I am using 4 producers and 3 readers in a microservice, and I would like to be able to enable / disable the logger for a given producer / reader and not to have to shut it down for all or have it logging for all. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] yuanweikang2020 commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
yuanweikang2020 commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-755245818


   like this.
   `func init() {
     // Log as JSON instead of the default ASCII formatter.
     logrus.SetFormatter(&logrus.JSONFormatter{})
   
     // Output to stdout instead of the default stderr
     // Can be any io.Writer, see below for File example
     logrus.SetOutput(os.Stdout)
   
     // Only log the warning severity or above.
     logrus.SetLevel(logrus.WarnLevel)
   }`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] Liberxue commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
Liberxue commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-929910696


   this's set logrus ErrorLevel example 
   ```go
   	pulsarLog := logrus.StandardLogger()
   	pulsarLog.SetLevel(logrus.ErrorLevel)
   	client, err := pulsar.NewClient(
   		pulsar.ClientOptions{
   			URL:               http://localhost:6501,
   			Authentication:    pulsar.NewAuthenticationToken(xxxx),
   			OperationTimeout:  15 * time.Second,
   			ConnectionTimeout: 47 * time.Second,
   			Logger:            log.NewLoggerWithLogrus(pulsarLog),
   		})
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] JoseFMP commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
JoseFMP commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-751583642


   @merlimat 
   Thank you so much. Still, I am not sure how I can disable or redirect the output. I saw the doucmentation of Logrus. However, how do I in practice disable it or redirect it if I am using pulsar client? Sorry, it does not seem obvious to me.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] Liberxue edited a comment on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
Liberxue edited a comment on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-929910696


   this's set logrus ErrorLevel example 
   ```go
   	pulsarLog := logrus.StandardLogger()
   	pulsarLog.SetLevel(logrus.ErrorLevel)
   	client, err := pulsar.NewClient(
   		pulsar.ClientOptions{
   			URL:               "http://localhost:6501",
   			Authentication:    pulsar.NewAuthenticationToken(xxxx),
   			OperationTimeout:  15 * time.Second,
   			ConnectionTimeout: 47 * time.Second,
   			Logger:            log.NewLoggerWithLogrus(pulsarLog),
   		})
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] Liberxue edited a comment on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
Liberxue edited a comment on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-929910696


   this's set logrus ErrorLevel example 
   ```go
   	pulsarLog := logrus.StandardLogger()
   	pulsarLog.SetLevel(logrus.ErrorLevel)
   	client, err := pulsar.NewClient(
   		pulsar.ClientOptions{
   			URL:               "http://localhost:6501",
   			Authentication:    pulsar.NewAuthenticationToken(xxxx),
   			OperationTimeout:  15 * time.Second,
   			ConnectionTimeout: 47 * time.Second,
   			Logger:            log.NewLoggerWithLogrus(pulsarLog),
   		})
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] Liberxue commented on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
Liberxue commented on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-929910696


   this's set logrus ErrorLevel example 
   ```go
   	pulsarLog := logrus.StandardLogger()
   	pulsarLog.SetLevel(logrus.ErrorLevel)
   	client, err := pulsar.NewClient(
   		pulsar.ClientOptions{
   			URL:               http://localhost:6501,
   			Authentication:    pulsar.NewAuthenticationToken(xxxx),
   			OperationTimeout:  15 * time.Second,
   			ConnectionTimeout: 47 * time.Second,
   			Logger:            log.NewLoggerWithLogrus(pulsarLog),
   		})
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] yuanweikang2020 edited a comment on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
yuanweikang2020 edited a comment on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-755245818


   like this.  
   
   ```
   func init() {
     // Log as JSON instead of the default ASCII formatter.
     logrus.SetFormatter(&logrus.JSONFormatter{})
   
     // Output to stdout instead of the default stderr
     // Can be any io.Writer, see below for File example
     logrus.SetOutput(os.Stdout)
   
     // Only log the warning severity or above.
     logrus.SetLevel(logrus.WarnLevel)
   }
   ```
   
   You can os.Stdout replace your logger writer.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] yuanweikang2020 edited a comment on issue #430: Disable logger

Posted by GitBox <gi...@apache.org>.
yuanweikang2020 edited a comment on issue #430:
URL: https://github.com/apache/pulsar-client-go/issues/430#issuecomment-755245818


   like this.  
   
   ```
   func init() {
     // Log as JSON instead of the default ASCII formatter.
     logrus.SetFormatter(&logrus.JSONFormatter{})
   
     // Output to stdout instead of the default stderr
     // Can be any io.Writer, see below for File example
     logrus.SetOutput(os.Stdout)
   
     // Only log the warning severity or above.
     logrus.SetLevel(logrus.WarnLevel)
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org