For PostgreSQL 8.3 installations on Ubuntu, the default server log location is typically:
/var/log/postgresql/postgresql-8.3-main.log
This path follows the standard Ubuntu/Debian convention for PostgreSQL log files. The exact filename might vary slightly depending on your cluster name, but will generally follow the pattern postgresql-{version}-{cluster}.log
.
If you can't locate the logs in the default location, try these methods:
# Check PostgreSQL configuration
grep log_directory /etc/postgresql/8.3/main/postgresql.conf
grep log_filename /etc/postgresql/8.3/main/postgresql.conf
# Search the filesystem for likely locations
sudo find /var/log -name "*postgres*" -type f
sudo find / -name "pg_log" -type d 2>/dev/null
To modify log settings in PostgreSQL 8.3, edit the configuration file:
sudo nano /etc/postgresql/8.3/main/postgresql.conf
Key parameters to check or modify:
# Directory to store log files
log_directory = 'pg_log'
# Log file name pattern
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
# Log statement controls
log_statement = 'all' # none, ddl, mod, all
For systems without logrotate already configured, you can add this to /etc/logrotate.d/postgresql-8.3
:
/var/log/postgresql/postgresql-8.3-main.log {
weekly
missingok
rotate 12
compress
delaycompress
notifempty
create 640 postgres adm
sharedscripts
postrotate
/etc/init.d/postgresql reload >/dev/null
endscript
}
Use these commands to monitor logs as they're written:
# Basic tail
sudo tail -f /var/log/postgresql/postgresql-8.3-main.log
# Tail with grep filtering
sudo tail -f /var/log/postgresql/postgresql-8.3-main.log | grep ERROR
# Use less for backward navigation
sudo less +F /var/log/postgresql/postgresql-8.3-main.log
If logs aren't appearing where expected:
- Verify the PostgreSQL service is running:
sudo service postgresql-8.3 status
- Check for configuration errors:
sudo -u postgres psql -c "SHOW log_directory;"
- Ensure proper permissions:
sudo chown postgres:adm /var/log/postgresql
- Restart PostgreSQL after configuration changes:
sudo service postgresql-8.3 restart
For PostgreSQL 8.3 installations on Ubuntu, server logs are typically found in:
/var/log/postgresql/postgresql-8.3-main.log
This path follows the standard Ubuntu/Debian logging conventions. The filename may vary slightly depending on your cluster name (here "main" is the default cluster).
If logs aren't in the default location, check these configuration approaches:
1. Checking postgresql.conf
The primary configuration file usually contains logging directives:
# Connect to PostgreSQL
psql -U postgres
# Show config file location
SHOW config_file;
# Or check logging parameters
SHOW log_directory;
SHOW log_filename;
2. System Service Configuration
Ubuntu's init script may override logging locations. Check the service file:
cat /etc/init.d/postgresql-8.3 | grep log
Case 1: Custom Log Location
If you've specified a custom log_directory in postgresql.conf:
log_directory = '/var/log/pg_logs'
log_filename = 'postgresql-%Y-%m-%d.log'
You'll need to check the configured directory.
Case 2: Syslog Configuration
When using syslog (common in older versions):
# Check syslog configuration
grep postgres /etc/syslog.conf
# Or search system logs
grep postgres /var/log/syslog
Example 1: Rotating Logs
Add log rotation configuration in /etc/logrotate.d/postgresql-8.3:
/var/log/postgresql/postgresql-8.3-main.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 640 postgres adm
sharedscripts
postrotate
/etc/init.d/postgresql-8.3 reload > /dev/null
endscript
}
Example 2: Increasing Log Verbosity
To debug issues, modify postgresql.conf:
log_min_messages = debug1
log_min_error_statement = debug1
log_connections = on
log_disconnections = on
log_statement = 'all'
Remember to reload the configuration after changes:
sudo /etc/init.d/postgresql-8.3 reload