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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-13-2011, 10:25 AM
|
#1
|
LQ Newbie
Registered: Jan 2011
Location: medan
Posts: 10
Rep:
|
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...
|
|
|
04-13-2011, 12:27 PM
|
#2
|
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
|
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?
|
|
|
04-13-2011, 07:01 PM
|
#3
|
LQ Newbie
Registered: Jan 2011
Location: medan
Posts: 10
Original Poster
Rep:
|
which library i should use? And how it works?
|
|
|
04-13-2011, 07:04 PM
|
#4
|
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
|
|
|
|
04-13-2011, 07:39 PM
|
#5
|
LQ Newbie
Registered: Jan 2011
Location: medan
Posts: 10
Original Poster
Rep:
|
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...
|
|
|
04-14-2011, 06:09 AM
|
#6
|
LQ Newbie
Registered: Jan 2011
Location: medan
Posts: 10
Original Poster
Rep:
|
Quote:
Originally Posted by MTK358
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...
|
|
|
04-14-2011, 07:51 AM
|
#7
|
LQ 5k Club
Registered: Sep 2009
Posts: 6,443
|
Then mark the thread as solved (unless you feel that you still didn't get a good solution).
|
|
|
All times are GMT -5. The time now is 04:47 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|