Setting up logging for a PostgreSQL server using syslog on a Linux machine is intuitive especially with logging systems like syslog-ng, you just need to put the correct parameters at the right place.

First, you need to setup the system side, by adding the following settings in /etc/syslog-nd/syslog-nd.conf (or similar, don’t hesitate to customize that with your own paths).
destination postgres { file("/var/log/pgsql"); };
filter f_postgres { facility(local0); };
log { source(src); filter(f_postgres); destination(postgres); };

This will send all the logs of postgresql server to /var/log/pgsql. Be sure to combine that with some solution rotating log files to avoid a single file becoming too large… And reload syslog-ng with a command similar to that (varies depending on distribution used, here Archlinux).
systemctl reload syslog-ng

Then, you need to add those settings in postgresql.conf.
log_destination = 'syslog' # Can specify multiple destinations
syslog_facility='LOCAL0'
syslog_ident='postgres'

Based on the documentation, syslog_facility can be set from LOCAL0 to LOCAL7.
Don’t forget that you can also specify multiple log destinations. For example when using stderr and syslog at the same time, simply do that:
log_destination = 'stderr,syslog'

Finally, reload the parameters of server and you are done.
pg_ctl reload -D $PGDATA
Note that restarting the server is not necessary.

In one word, Arch Linux is AWESOME. It is the first distribution of Linux that I use giving me the feeling that I control everything in my environment. Among its strengths, its package manager pacman makes everything very flexible and once you migrate to it, you don’t need to worry about support time or anything like for Ubuntu distributions or most of the major distributions.

However setting up an Arch environment is honestly a pain for noobs.
So, based on my *painful* experience, I created some manuals that can be used to install an ArchLinux environment using XFCE as Desktop.
So here is the list of manuals.

Those manuals are not perfect, but give good guidelines of my migration experience. Enjoy!

With ImageMagick package (image manipulation library) installed on a Linux machine, it is possible to split a huge image file into smaller tiles with such kind of command:
convert -crop $WIDTHx$HEIGHT@ huge_file.png tile_%d.png

With the following parameters.

  • $WIDTH, the width of each tile splitted
  • $HEIGHT, the height of each tile splitted

Here is an example to split a file into tiles of size 16×32 pixels:
convert -crop 16x32@ huge_file.png tile_%d.png

When creating files in Windows, those files will have the DOS format.
This creates annoying ^M characters at the end of lines, which can be seen in patches or diff files.

In order to localize them, use this command:
find . -not -type d -exec file "{}" ";" | grep CRLF
It will give an output like this for dos files:
./example.txt: ASCII text, with CRLF line terminators

Then open them in emacs, and launch that command:
M-x set-buffer-file-coding-system RET undecided-unix
M-x means escape and X.
RET is return.
Then save your file and you are done.

Modifying the format name of dump file in a Linux system can be made with sysctl like this.
sysctl -w kernel.core_pattern=core.%e.%p
However, making this modification command-based will not make it effective at next reboot.

In order to make the modification permanent, you need to edit the file /etc/sysctl.conf. Here the core file has the executable name %e and the process ID %p.
kernel.core_pattern = core.%e.%p

Here is a list of the possible keywords usable:

  • %p, PID of dumped process
  • %u, (numeric) real UID of dumped process
  • %g, (numeric) real GID of dumped process
  • %s, number of signal causing dump
  • %t time of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
  • %h, hostname (same as nodename returned by uname(2))
  • %e, executable filename (without path prefix)
  • %c, core file size soft resource limit of crashing process (since Linux 2.6.24)
©2010-2013 Michael Paquier All content is ©Copyright of Otacoo.com 2010-2013. Privacy Policy - Terms of Use