This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Reading log file using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading log file using Java" Watch "Reading log file using Java" New topic

Reading log file using Java

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39


I have a requirement where I have to setup a cron job using java which will connect to a unix box and read the app server log files by SSH library, like JSch.

Basically I have to read three things from log:

1. Exception stack trace/error code (app generated) if there is any,
2. User sessionID.
3. Time Stamp.

Connecting to unix box using third party code is fine. Challenge here for me is extracting the session id and timestamp each time an exception error occur on our servers.

I know that log file is a plain text file so, java pattern and string manipulation is required here.

Could anyone give me some ways to do this

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Sorry I guess I have posted it in the wrong forum.

Moderators: Could you please move it to "Java in General" or in appropriate forum if required


Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

You have a big bag of miscellaneous requirements there. So when you ask how to do "this", you ask a very unclear question. What is "this"? Do you not know how to do any of those things? Or do you have questions about some of them? If so, which ones?
Victor Ramen
Ranch Hand

Joined: Jul 14, 2008
Posts: 56
Are you asking for how to parse a file for a particular text using java?
Don't get me started about those stupid light bulbs.
subject: Reading log file using Java
Similar Threads
Strange Problem in Running Jar!
exception stack trace not going to log file
Too many opne files
Trying to read a file on Unix into a file on windows or into a string builder
Connecting to Unix via Windows