Thread: Win32: missing log file option for pg_ctl running as service

Win32: missing log file option for pg_ctl running as service

From
"Steve McWilliams"
Date:
When running pg_ctl as a windows service (WinXP Pro), I don't see any way
currently to configure a log file for it to use.  I am using the following
syntax to register pg_ctl as a service:

pg_ctl register -N MyService -U myUser -P myPword -D myDataDir -w -o "-i"

A "-l myLog" option passed in would get ignored, according to pg-ctl.c.
Is there some other way that we should be configuring a log file when
running pg_ctl as a service on windows?

Thanks.

Steve McWilliams
Software Engineer
Emprisa Networks
703-691-0433x21
smcwilliams@emprisanetworks.com

The information contained in this communication is intended only for the
use of the recipient named above, and may be legally privileged,
confidential and exempt from disclosure under applicable law. If the
reader of this communication is not the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication, or any of its contents, is strictly prohibited. If you have
received this communication in error, please resend this communication to
the sender and delete the original communication and any copy of it from
your computer system. Thank you.

Re: Win32: missing log file option for pg_ctl running as service

From
"Magnus Hagander"
Date:
>When running pg_ctl as a windows service (WinXP Pro), I don't=20
>see any way
>currently to configure a log file for it to use.  I am using=20
>the following
>syntax to register pg_ctl as a service:
>
>pg_ctl register -N MyService -U myUser -P myPword -D myDataDir=20
>-w -o "-i"
>
>A "-l myLog" option passed in would get ignored, according to=20
>pg-ctl.c.=20
>Is there some other way that we should be configuring a log file when
>running pg_ctl as a service on windows?

Yes, see the redirect_stderr parameter in postgresql.conf.
It should be enabled by default in the pginstaller installation.

//Magnus

Re: Win32: missing log file option for pg_ctl running as service

From
"Gurjeet Singh"
Date:
>>When running pg_ctl as a windows service (WinXP Pro), I don't
>>see any way
>>currently to configure a log file for it to use.  I am using
>>the following
>>syntax to register pg_ctl as a service:
>>
>>pg_ctl register -N MyService -U myUser -P myPword -D myDataDir
>>-w -o "-i"
>>
>>A "-l myLog" option passed in would get ignored, according to
>>pg-ctl.c.
>>Is there some other way that we should be configuring a log file when
>>running pg_ctl as a service on windows?
>
>Yes, see the redirect_stderr parameter in postgresql.conf.
>It should be enabled by default in the pginstaller installation.
>
>//Magnus

Hi Magnus,

    I tried what you said, but the LOG/ERROR/FATAL messages are all
getting logged into Windows (Win2k) 'Event Log', and are visible via
'Event Viewer' under 'Application Log'.

    I am building from sources, and I just uncommented the GUC in
question from the conf file:

# - Where to Log -

log_destination =3D 'stderr'        # Valid values are combinations of
                    # stderr, syslog and eventlog,
                    # depending on platform.

# This is used when logging to stderr:
redirect_stderr =3D off            # Enable capturing of stderr into log
                    # files

# These are only used if redirect_stderr is on:
log_directory =3D 'pg_log'        # Directory where log files are written
                    # Can be absolute or relative to PGDATA
log_filename =3D 'postgresql-%Y-%m-%d_%H%M%S.log' # Log file name pattern.
                    # Can include strftime() escapes
log_truncate_on_rotation =3D off # If on, any existing log file of the same
                    # name as the new log file will be
                    # truncated rather than appended to. But
                    # such truncation only occurs on
                    # time-driven rotation, not on restarts
                    # or size-driven rotation. Default is
                    # off, meaning append to existing files
                    # in all cases.
#log_rotation_age =3D 1440        # Automatic rotation of logfiles will
                    # happen after so many minutes.  0 to
                    # disable.
log_rotation_size =3D 10240        # Automatic rotation of logfiles will
                    # happen after so many kilobytes of log
                    # output.  0 to disable.

Thanks in advance,
Gurjeet.

Re: Win32: missing log file option for pg_ctl running as service

From
"Gurjeet Singh"
Date:
Reference (http://archives.postgresql.org/pgsql-bugs/2004-09/msg00185.php).
Also, I am regsitering the service as follows:

...> pg_ctl register -N postgres -U username -P passwd -D F:\pgsql\data

    I can connect to the cluster using psql and work just normally.
But wish to redirect the log entries to a FS log fle instead of OS
event log!!!

Thanks,
Gurjeet.

On 5/28/06, Gurjeet Singh <singh.gurjeet@gmail.com> wrote:
> >>When running pg_ctl as a windows service (WinXP Pro), I don't
> >>see any way
> >>currently to configure a log file for it to use.  I am using
> >>the following
> >>syntax to register pg_ctl as a service:
> >>
> >>pg_ctl register -N MyService -U myUser -P myPword -D myDataDir
> >>-w -o "-i"
> >>
> >>A "-l myLog" option passed in would get ignored, according to
> >>pg-ctl.c.
> >>Is there some other way that we should be configuring a log file when
> >>running pg_ctl as a service on windows?
> >
> >Yes, see the redirect_stderr parameter in postgresql.conf.
> >It should be enabled by default in the pginstaller installation.
> >
> >//Magnus
>
> Hi Magnus,
>
>     I tried what you said, but the LOG/ERROR/FATAL messages are all
> getting logged into Windows (Win2k) 'Event Log', and are visible via
> 'Event Viewer' under 'Application Log'.
>
>     I am building from sources, and I just uncommented the GUC in
> question from the conf file:
>
> # - Where to Log -
>
> log_destination =3D 'stderr'              # Valid values are combinations=
 of
>                                         # stderr, syslog and eventlog,
>                                         # depending on platform.
>
> # This is used when logging to stderr:
> redirect_stderr =3D off                   # Enable capturing of stderr in=
to log
>                                         # files
>
> # These are only used if redirect_stderr is on:
> log_directory =3D 'pg_log'                # Directory where log files are=
 written
>                                         # Can be absolute or relative to =
PGDATA
> log_filename =3D 'postgresql-%Y-%m-%d_%H%M%S.log' # Log file name pattern.
>                                         # Can include strftime() escapes
> log_truncate_on_rotation =3D off # If on, any existing log file of the sa=
me
>                                         # name as the new log file will be
>                                         # truncated rather than appended =
to. But
>                                         # such truncation only occurs on
>                                         # time-driven rotation, not on re=
starts
>                                         # or size-driven rotation. Defaul=
t is
>                                         # off, meaning append to existing=
 files
>                                         # in all cases.
> #log_rotation_age =3D 1440                # Automatic rotation of logfile=
s will
>                                         # happen after so many minutes.  =
0 to
>                                         # disable.
> log_rotation_size =3D 10240               # Automatic rotation of logfile=
s will
>                                         # happen after so many kilobytes =
of log
>                                         # output.  0 to disable.
>
> Thanks in advance,
> Gurjeet.
>