Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable logging/tracing #2273

Open
emaborsa opened this issue Mar 11, 2025 · 5 comments
Open

How to disable logging/tracing #2273

emaborsa opened this issue Mar 11, 2025 · 5 comments

Comments

@emaborsa
Copy link

emaborsa commented Mar 11, 2025

I am working with with pgxpool v5, this is how I create the pool:

const timeout = time.Second * 90

func initDatabasePool(connString string) (*pgxpool.Pool, error) {
	config, err := pgxpool.ParseConfig(connString)
	if err != nil {
		return nil, err
	}

	config.MaxConnLifetime = timeout 
	config.MaxConnIdleTime = timeout 

	return pgxpool.NewWithConfig(context.Background(), config)
}

The database prints everything to console. How can I prevent it from that? I tryied to add config.ConnConfig.Tracer = nil, but doesn't help.

@felix-roehrich
Copy link
Contributor

pgx doesn't log anything to the console with default settings. Please check your own code for any statements that print and, if you can't find anything, please create a repo with a minimal example that reproduces the problem.

@emaborsa
Copy link
Author

I checked my code, did not find and print statement. Let's take this snippet from my code:

rows, err := r.pool.Query(ctx, query, args...)

If I set a break point at this line, the console is clear. Once i hit F10, the query is printed to console, this means it must be a setting, right?

@felix-roehrich
Copy link
Contributor

As I said before, pgx does not log anything if you use default settings. My best guess is that you have some other logging utility configured which triggers this.
The best way to check if this is really a problem with pgx is to create a clean project with pgx only and try to see if the issue persists. If it does, then please post the example.

@emaborsa
Copy link
Author

OK, i got it, but could you tell me which setting would trigger this logging?

@jackc
Copy link
Owner

jackc commented Mar 15, 2025

Presumably, your connection https://pkg.go.dev/github.com/jackc/pgx/v5#ConnConfig has a Tracer set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants