We help IT Professionals succeed at work.

Procedure to LOG to a file!

VSF
VSF asked
on
I need general procedure, function or ideas about what would be the best way to create LOG files passing to the function only the IBDataset where the Editing or Deleting is being made!

Editing
The LOG should contain values of the fields before and after editing.

When Deleting
The LOG should contain values of the fields deleted.

Ps: I Know how to create a LOG and write to a file, what I need is a general and best way to do it!

Thanks Experts,
VSF
www.victory.hpg.com.br
victory@e-net.com.br
Comment
Watch Question

The way I'm creating log's or logfiles, is to use a Memo filed during runtime - then the user can see what's going on.
Then on CloseQuery event, I save the memo to file
Example:
Memo1.Lines.Add(FormatDateTime('hh:mm:ss', Time)+' Program started);
etc...
Memo1.Lines.SaveToFile('C:\Temp\MyLog.txt');

DelRunner
Igor UL7AAjrSenior developer

Commented:
Hi VSF,

I think that right way is to create log table inside your Interbase database instead of log file. The structure of the table is something like this:

EventTime date - date and time of operation
EventKind int - tpye of operation Editing, Deleting...
UserName varchar(nn) - name of user who did changes
TableName varchar(nn) - name of table for which data was changed
RecordData blob - packed data of record before modification, can be concatenation of all fields with some unique separator.

Then you have to write triggers for all tables which changes should be tracked:
BeforeDelete,
BeforeUpdate

----
Igor
VSF

Author

Commented:
ITugay:

Your suggestion sounds good!
I'm starting with Interbase now and a working sample or at least some code would be of great help!

I also think that logging into a database is a better idea, because I can make a report screen to filter the logs and see exactly the logged changes I want!

Please post some code or a link to a sample!
Thanks!

VSF
www.victory.hpg.com.br
victory@e-net.com.br

VSF

Author

Commented:
I'm having some problems on creating the trigger to concatenate the fields changed!

Can you please help me posting some sample code?!?!!

Thanks
VSF
VSF

Author

Commented:
tic tac...
still need the sample or any other ideas!

VSF
www.victory.hpg.com.br
www.boatoda.hpg.com.br
victory@e-net.com.br

 
Senior developer
Commented:
hi VSF,

here is a sample of trigger that concatenates three fields and places result into the field named "totalstr" with type of memo.

I hope it may help you a little bit.

CREATE TRIGGER SOMEDATA_BEFOREUPDATE FOR SOMEDATA BEFORE UPDATE POSITION 0 AS
declare variable F1 varchar(100);
declare variable F2 varchar(100);
declare variable F3 varchar(100);
BEGIN
  F1 = cast(new.ID as varchar(10));
  F2 = cast(new.datefield as varchar(30));
  F2 = cast(new.int_value as varchar(30));

  if (F1 is null) then F1 = '...';
  if (F2 is null) then F2 = '...';
  if (F3 is null) then F3 = '...';

  new.totalstr = F1 || ', ' || F2 || ', ' || F3;

END

----
Igor
Asta CuTechnical consultant & graphic design
CERTIFIED EXPERT
Top Expert 2004

Commented:
Hopefully you've already been helped with this question, but thought you'd appreciate knowing this.  It would be great if you could bring this question to a conclusion, awarding the experts above who helped you with points or a comment to them on your status today.

WindowsUpdate has new updates for .NET users; Details follow - Microsoft .NET Framework
The .NET Framework is a new feature of Windows. Applications built using the .NET Framework are more reliable and secure. You need to install the .NET Framework only if you have software that requires it.

For more information about the .NET Framework, see http://www.microsoft.com/net. (This site is in English.)

System Requirements
The .NET Framework can be installed on the following operating systems:
Windows 98
Windows 98 Second Edition (SE)
Windows Millennium Edition (Windows Me)
Windows NT 4.0® (Workstation or Server) with Service Pack 6.0a
Windows 2000 with the latest service pack installed (Professional, Server, Datacenter Server, or Advanced Server)
Windows XP (Home Edition and Professional)
You must be running Internet Explorer version 5.01 or later for all installations of the .NET Framework.

To install the .NET Framework, your computer must meet or exceed the following software and hardware requirements:

Software requirements for server operating systems:
MDAC 2.6
Hardware requirements:
For computers running only a .NET Framework application, Pentium 90 mHz CPU with 32 MB memory or the minimum CPU and RAM required by the operating system, whichever is higher.
For server operating systems, Pentium 133 mHz CPU with 128 MB memory or the minimum CPU and RAM required by the operating system, whichever is higher.
Recomended software:
MDAC 2.7 is recommended.
Recommended hardware: For computers running only a .NET Framework application, Pentium 90 MHz CPU with 96 MB memory or the minimum CPU and RAM required by the operating system, whichever is higher.
For server operating systems, Pentium 133 MHz CPU with 256 MB memory or the minimum CPU and RAM required by the operating system, whichever is higher.

How to use -> Restart your computer to complete the installation. No other action is required to run .NET Framework applications. If you are developing applications using the .NET Framework, you can use the command-line compilers or you can use a development environment, such as Visual Studio .NET, that supports using the .NET Framework.

How to uninstall
To uninstall the .NET Framework: Click Start, point to Settings, and then click Control Panel (In Windows XP, click Start and then click Control Panel.).
Click Add/Remove Programs.
Click Microsoft .NET Framework (English) v1.0.3705 and then click Change/Remove.
More here  http://www.microsoft.com/net/

The .NET topic is being considered for addition to our All Topics link soon, so this may interest you as well:
http://www.experts-exchange.com/newtopics/Q.20276589.html

EXPERTS POINTS are waiting to be claimed here:  http://www.experts-exchange.com/commspt/Q.20277028.html

":0)
Asta


VSF

Author

Commented:
This should do it!
Thanks!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.