tags:

views:

257

answers:

8

Hi,

I'm not sure if it was asked, but I couldn't find anything like this.

My program uses a simple .txt file for log purposes, It just creates/opens a file and appends lines.

After some time, I started to log quite a lot of activities, so the file became too large and hardly readable. I know, that it's not write way to do this, but I simply need to have a readable file.

So I thought maybe there's a simple file format for log files and a soft to view it or if you'd have any other suggestions on this question?

Thanks for help in advance.

UPDATE:

It's access 97 application. I'm logging some activities like Form Loading, SELECT/INSERT/UPDATE to MS SQL Server ... The log file isn't really big, I just write the duration of operations, so I need a simple way to do this.

The Log file is created on a user's machine. It's used for monitoring purposes logging some activities' durations.

Is there a way of viewing that kind of simple Log file highlighted with an existing tool?

Simply, I'd like to:

1) Write smth like "'CurrentTime' 'ActivityName' 'Duration in milliseconds' " (maybe some additional information like query string) into a file.

2) Open it with a tool and view it highlighted or somehow more readable.

ANSWER: I've found a nice tool to do all I've wanted. Check my answer.

LogExpert

+3  A: 

The 3 W's :

When, what and where.

For viewing something like multitail ("tail on steroids") http://www.vanheusden.com/multitail/

or for pure ms windows try mtail http://ophilipp.free.fr/op_tail.htm

And to keep your files readable, you might want to start new files when if the filesize of the current log file is over certain limit. Example:

  • activity0.log (1 mb)
  • activity1.log (1 mb)
  • activity2.log (1 mb)
  • activity3.log (1 mb)
  • activity4.log (205 bytes)
zaf
hmm..helpful advice. Thanks :)
hgulyan
but is there a way to make it understandable for an app?
hgulyan
What do you mean "understandable for an app"? With multitail you can filter or highlight entries in various ways.
zaf
@thephpdeveloper thanks for the cleanup job. Why remove multitail reference? Was it not useful?
zaf
@zaf - I think we submitted the changes at the same time thus resulting in the removal. added that back!
thephpdeveloper
@thephpdeveloper +1 sherlock.
zaf
and that's why I didn't see the link. Does it work on Windows?
hgulyan
@zaf, It says that I need cygwin for Windows, but I can't figure it out how.
hgulyan
@hgulyan For windows try mtail from http://ophilipp.free.fr/op_tail.htm
zaf
@zaf, is there any possibility to highlight the text or something like that in mtail?Is it used just for monitoring purposes?
hgulyan
@hgulyan You can setup filters. Other than that, I don't know since I don't use it now. There are other similar programs, just google it and try them - I'm sure one of them will be near enough to what you want.
zaf
@zaf, there're really a lot of Log Viewer programs, but I don't see any difference to view it with them or just with notepad. I don't need the main purpose of tail - viewing changes while the file is opened.
hgulyan
@zaf, anyway, it's better than other solutions. I'll wait for other suggestions and if I don't find nothing better, I'll just accept your answer, but I really wished to have something better. Thank you.
hgulyan
@hgulyan Then use a text editor that remembers the last 'find'. I think vim does this. I would personally create a (web?) script that does this for me.
zaf
@zaf, I'm thinking of a way to insert the log file into a table and write an app to view it readable and with some search options
hgulyan
@zaf, I've found a better tool.
hgulyan
@hgulyan what is it?
zaf
@zaf, I've added my answer and to my question with some links. LogExpert.
hgulyan
+1  A: 

First, check you're only logging things that are useful.

If it's all useful, make sure it is easily parsable by tools such as grep, that way you can find the info you want. Make sure you have the type of log entry, the date/time all conforming to a layout.

Build yourself a few scripts to extract the information for you. Alternatively, use separate log files for different types of entries.

Steven Jackson
I try to find an existing tool.
hgulyan
+1  A: 

Basically you better just split logs according to severity. You'll rarely need to read all logs for the whole system. For example apache allows to configure error log and access log, pretty obvious what info exactly they have.

If you're under linux system grep is your best tool to search through logs for specific entries.

Juriy
The log file is creating on a user's computer with WinXp on it
hgulyan
+1  A: 

Look at popular logfiles like /var/log/syslog on Unix to get ideas:

MMM DD HH:MM:SS hostname process[pid]: message

Example out of my syslog:

May 11 12:58:39 raphaelm anacron[1086]: Normal exit (1 job run)

But to give you the perfect answer we'd need more information about what you are logging, how much and how you want to read the logs.

rami
But if I save a file in txt format, it won't be highlighted or smth like it to make the log file more readable. I've edited my question.
hgulyan
The ending of the name (.txt or .log or someting else) isn't relevant for the content. Maybe you want to give us an example of your current log files?
rami
I can write the log file in any way. What I need is a some kind of file format, that can be understand by a program, that will show me the log file highlighted or somehow more readable.
hgulyan
Do you want to write such a program to highlight or are you looking for an existing one? In second case, what's about for example CSV (=> Excel)? It isn't *real* highlighting, I know, but it's searchable, column-based and popular. And: in combination with log-rotation or splitting to several files…
rami
I thought of an existing tool for a log file. Excel can be used in my case, but it isn't a simple and fast way. Talking simply, I'd like to write smth like "11/05/10 14:32:00 <ActivityName> <Duration in milliseconds> " (maybe some additional information like query string) into a file, open it with a tool and view it highlighted or somehow more readable.
hgulyan
Hmm. I'm sorry, but I don't know a tool for doing this.
rami
@rami Thank you in any case, your example and advice is very useful.
hgulyan
+1  A: 

If only the size of the log file is the problem, I recommend using logrotate or something similar. logrotate watches log files and, depending on how you configured it, after a given time or when the log file exceeds a given size, it moves the log file to an archive directory and optionally compresses it. Then the original log file is truncated. For example, you could configure it to archive the log file every 24 hours or whenever the files size exceeds 500kb.

jkramer
No, the main problem is that it's not readable. I wished to find a GUI to view it, but thanks for the answer. Didn't know about logrotate.
hgulyan
+1  A: 

If this is a program, you might investigate apache logging libraries (http://logging.apache.org/) Out of the box, they'll give you a decent logging format out of the box. They're also customizable, so you can simplify your parsing job.

If this is a script, see some of the other answers.

Andrew B
I've used Log4j in Java, but there's nothing helpful in old MS Access 97 for logging.
hgulyan
+1  A: 

A fairly standard way to deal with logging from an application into a plain text file is to:

  • split the logs into different program functional areas.
  • rotate the logs on a daily/weekly basis (i.e. split the log on a size or date basis)
    • so the current log is "mylog.log" or whatever, and yesterday's was "mylog.log.1" or "mylog.ddmmyyyy.log"

This keeps the size of the active log manageable. And then you can just have expiry rules so that old logs get thrown away on a regular basis.

In addition it would be a good idea to have different log levels for your application (info/warning/error/fatal) so that you're not logging more than is necessary.

liamf
Thanks. Yeah, that would be right to have severity, but I use my log file for monitoring purposes and I log some activities durations, not errors.
hgulyan
A: 

LogExpert

I've found it here. Filter is better, than in mtail. There's an option of highlighting just adding a string and the app is nice and readable. You can customize columns as you like.

http://stackoverflow.com/questions/113121/best-tail-log-file-visualization-freeware-tool

hgulyan