RE: Logging Question

RE: Logging Question

am 09.11.2005 21:40:10 von imharisa

------_=_NextPart_001_01C5E56D.C7174B34
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I would look to using Log::Log4perl for all your logging needs. But for
what you are doing try setting $| =3D 1 (autoflush).

________________________________

From: Vergara, Michael (TEM) [mailto:mvergara@guidant.com]=20
Sent: Wednesday, November 09, 2005 1:25 PM
To: dbi-users@perl.org
Subject: Logging Question


Hello Everyone:
=20
I have a Perl script that connects to multiple Oracle databases. I have
the script write some status information to=20
a log file. There is one particular database that hangs in processing,
and I don't know why. The log file does not seem
to be written until the file is closed.
=20
I am wondering, is there a Perl command or technique that will force
lines that are logically written to a log file to be
physically written to that file?
=20
Here's my opening code:
#
#
------------------------------------------------------------ ------------
-
# Open Log file
#
------------------------------------------------------------ ------------
-
my $logFileName =3D "${HomeDir}/work/monitor/output/logs/db_status.log";
open( LOGF, ">>" . $logFileName ) or die "\nCannot open log file\n\n";
print LOGF "\n----------\n";
print LOGF sprintf("db_status started at %02d-%02d-%04d
%02d:%02d:%02d\n",
$Tm->mon+1, $Tm->mday, $Tm->year+1900, $Tm->hour,
$Tm->min, $Tm->sec );
=20
=20
The line that says 'db_status started...' does not get written for the
hanging system because I usually 'kill -9' or 'Ctrl-C'
the process. I'd like to force a write after each section so I can see
there the process is hanging.
=20
Any help will be appreciated.
=20
Thanks,
Mike
=20
________________________________

Michael P. Vergara Be good and you will be lonesome=09
Oracle Database Administrator Mark Twain=09
(951) 914-2000 (Voice) =09
(951) 914-2990 (FAX) =09
www.guidant.com =09

Any views expressed herein are not necessarily those of Guidant
Corporation. =09
=20

------_=_NextPart_001_01C5E56D.C7174B34--

Re: Logging Question

am 09.11.2005 21:48:02 von csarnows

On Nov 9, 2005, at 3:40 PM, Ian Harisay wrote:

> I would look to using Log::Log4perl for all your logging needs.
> But for
> what you are doing try setting $| = 1 (autoflush).


and on Nov 9, 2005, at 3:38 PM, Chris Sarnowski wrote:
> This is a perl issue, not a DBI issue, but try
>
> autoflush LOGF 1;
>
> after you open LOGF.
>
> This should force a flush after every print statement. If it
> doesn't work I hope that at least it points you the right direction.

I hate to extend an off-topic thread too far, but
$| = 1
only works on the 'select'ed file handle (default STDOUT)

and for my suggestion, you need to

use FileHandle;

-Chris

Re: Logging Question

am 09.11.2005 21:53:43 von cgehring

--=_alternative 0072C7BD852570B4_=
Content-Type: text/plain; charset="US-ASCII"

I agree, a bit off topic, but for my log files I use the following code:

my $TempSelect = select( LOGF );
$| = 1;
select( $TempSelect );





Chris Sarnowski
11/09/2005 03:48 PM

To
dbi-users@perl.org
cc

Subject
Re: Logging Question







On Nov 9, 2005, at 3:40 PM, Ian Harisay wrote:

> I would look to using Log::Log4perl for all your logging needs.
> But for
> what you are doing try setting $| = 1 (autoflush).


and on Nov 9, 2005, at 3:38 PM, Chris Sarnowski wrote:
> This is a perl issue, not a DBI issue, but try
>
> autoflush LOGF 1;
>
> after you open LOGF.
>
> This should force a flush after every print statement. If it
> doesn't work I hope that at least it points you the right direction.

I hate to extend an off-topic thread too far, but
$| = 1
only works on the 'select'ed file handle (default STDOUT)

and for my suggestion, you need to

use FileHandle;

-Chris



--=_alternative 0072C7BD852570B4_=--