LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2011, 10:25 AM   #1
ch41
LQ Newbie
 
Registered: Jan 2011
Location: medan
Posts: 10

Rep: Reputation: 0
Unread log entry when reading log in java


Hi all, i am a students that is learn in java linux programming.,

i want to make program that processing entry in log on real time...

I have try to pass "tail -f -n 1 /var/log/messages" command
from .runtime().exec and process the output,,

description of the algo is like this

-
passed to exec()
-read output
-if not same as previous value procces it

sorry for my bad description, because i write this from my phone

but sometimes it loose some entry to procces, maybe it occur when proccesing another entry is added by system...

Please let me know if you have any solution for the reading problem...

sorry for my bad english...
I am very appreciate for any reply...
 
Old 04-13-2011, 12:27 PM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Wouldn't it be a far better idea to read the log file with Java's own libraries, instead of relying on the system having a certain shell and utilities installed?
 
Old 04-13-2011, 07:01 PM   #3
ch41
LQ Newbie
 
Registered: Jan 2011
Location: medan
Posts: 10

Original Poster
Rep: Reputation: 0
which library i should use? And how it works?
 
Old 04-13-2011, 07:04 PM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Use Google:

http://www.google.com/search?client=...UTF-8&oe=UTF-8
 
Old 04-13-2011, 07:39 PM   #5
ch41
LQ Newbie
 
Registered: Jan 2011
Location: medan
Posts: 10

Original Poster
Rep: Reputation: 0
wait, that is standard i/o class in java,, i have use it, it works like periodicly read from start of the log and save the last point of entry by time in log entry,, but the same problem still occur because sometimes , entry on log are added by system in seconds,, so the reading is fail...
 
Old 04-14-2011, 06:09 AM   #6
ch41
LQ Newbie
 
Registered: Jan 2011
Location: medan
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MTK358 View Post
Wouldn't it be a far better idea to read the log file with Java's own libraries, instead of relying on the system having a certain shell and utilities installed?
thank you, but i have found solution for my problem, i am using class tailer from apache, it works prety good...
 
Old 04-14-2011, 07:51 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Then mark the thread as solved (unless you feel that you still didn't get a good solution).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kernel log format in /var/log/kern.log sinu_nayak2001 Linux - Newbie 2 10-07-2009 08:34 AM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
Reading the log files using Java sboothman Programming 3 11-16-2006 06:32 AM
Opennms Logs - where are web.log, web_rtc.log and webauth.log referenced? not_much_of_a_guru Linux - Networking 0 07-12-2006 10:28 AM
suspicious entry in /var/log/auth.log buehler Linux - Security 5 04-27-2005 05:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration