Reading .log file & Sorting input

Hello all
Currently I'm working on a projekt were I have to read a "in.log" file, sort it and save it to another "out.log" file, the contents of the in.log file is:
[204.0.44.73]: Dir: path
[204.0.44.73]: Dir: path
[204.0.44.74]: Dir: path
[204.0.44.73]: Dir: path
[204.0.44.74]: Dir: path
and so on, now what I have to end up with is this in the out.log:
#1
[204.0.44.73]: Dir: path
[204.0.44.73]: Dir: path
[204.0.44.73]: Dir: path
Count = 3
#2
[204.0.44.74]: Dir: path
[204.0.44.74]: Dir: path
Count = 2
It's for the system administrator at school who doesn't want to do it himself but wants to pay an amount for me to do it (very small amount). I'll pay max duke dollars for a reply which can help me..
Please help, thx in advance

I must be really bored... Use it with "java Parser <logname>"
import java.io.*;
import java.util.*;
public class Parser{
     public void splitLog( File input ){
          try{
               FileInputStream fis = new FileInputStream( input );
               BufferedReader br = new BufferedReader( new InputStreamReader( fis ) );
               Hashtable hosts = new Hashtable();
               String line;
               while( ( line = br.readLine() ) != null ){
                    StringTokenizer st = new StringTokenizer( line, "]" );
                    if( st.hasMoreTokens() ){
                         String host = st.nextToken();
                         if( host.trim().startsWith("[") ){
                              host = host.trim().substring(1);
                         if( !hosts.containsKey( host ) ){
                              hosts.put( host, new Vector() );
                         Vector v = (Vector)hosts.get( host );
                         v.addElement( line );
               Enumeration enum = hosts.keys();
               while( enum.hasMoreElements() ){
                    String host = (String)enum.nextElement();
                    Vector v = (Vector)hosts.get(host);
                    FileOutputStream fos = new FileOutputStream( host + ".log" );
                    for( int i = 0; i < v.size(); i++ ){
                         line = (String)v.elementAt( i );
                         fos.write( (line + "\r\n").getBytes());
                    fos.close();
          catch( Exception e ){
               e.printStackTrace();
     public static void main( String[] args ){
          File input = new File( args[0] );
          Parser parser = new Parser();
          parser.splitLog( input );
}

Similar Messages

  • Where are adobe reader log files?

    Where are the log files for Adobe Reader?
    When one of our clients opens a form off our liquid office server we receive an error.  If possible I would like to find a log file that might give some sort of clue as to why this is happening.  Thanks

    I'll make an inquiry about that and if we have to contact liquid office at some point my guess is they may request that we do that if there is likely to be any useful information there.  It is likely going to be pretty difficult as we have lots of clients opening forms constantly throughout the day.
    I did find adobearm log file and also adobereaerbroker log file in the temp files on my own.  So it does seem like reader logs some of it's activities.  I haven't examined them completely yet but a quick comparison between a working machine opening our problem form and the one the computer that doesn't open it properly seems to show no obvious differences.  They both seem to show problems with access denied and registry entries.  However one works and the other doesn't even with the same issues in the log.

  • IMP: How to Read LOG Files

    Hey Gurus,
       I want to read the log files after executing SE37 t-codes, I tried in sm21 but i didnt get any result.
       Can U tell me how to read the log files ??
       what is T-code for that? or i have change any settings???
      Thanking You,
        Regards
       J Sarathi

    Hi ,
    You can use these two FM for analysing the log ..
                   APPL_LOG_READ_INTERN
                   APPL_LOG_DISPLAY_INTERN
    Or You can create A Zprogram using this FM
    and check the changes using RSDEPEND

  • Allowing special user to read log files [Solved]

    Hi
    I want to add a group (log) that has the privledges to read /var/log files
    and then add my user to that group.
    How do i accomplish this
    This is to run root-tail in .xinitrc
    Or is there an other way?
    //Clanman

    [root@master fredrik]# ls -al /usr/bin/root-tail
    -rwxr-xr-x  1 root root 22600 2006-01-08 04:58 /usr/bin/root-tail
    [root@master fredrik]# chmod 640 /usr/bin/root-tail
    [root@master fredrik]# ls -al /usr/bin/root-tail
    -rw-r-----  1 root root 22600 2006-01-08 04:58 /usr/bin/root-tail
    [root@master fredrik]# chgrp log /usr/bin/root-tail
    [root@master fredrik]# ls -al /usr/bin/root-tail
    -rw-r-----  1 root log 22600 2006-01-08 04:58 /usr/bin/root-tail
    exiting root
    fredrik@master ~]$ root-tail -g 800x250+10+10 -justify -fn '-*-verdana-*-*-*-*-10-*-*-*-*-*-*-*' /var/log/errors.log,orange,'ALERT'
    -bash: /usr/bin/root-tail: Permission denied
    Still no go
    //Clanman

  • Any ideas creating app to read log file when updated?

    Afternoon all,
    I have been asked to write a java app which will read the contents of the server log file every time the log file is updated by the server. The app will be deployed onto WebSphere Application Server.
    Can anyone point me in the right direction as I have never written anything like this before and I don't know where to start. Any help will be much appreciated.
    Thanks in advance,
    A.

    alex@work wrote:
    I agree with most of what you've said but unfortunately I don't have a say in what the company wants. However, I am interested in the appender idea, perhaps they may go for that if I suggest it.I'd say it'll take you a day to read up about Log4J and how to write basic appenders, and another day to write your own appender for this problem. Compare that to the effort of writing something to poll a log file, re-read it constantly and update another file, operations which will get slower and slower as they go along. That's a fair amount more code than a single appender would be. There's how to sell it to your company.
    Can you give me a brief overview in how it works?Log4J uses objects called appenders, which take logging info - generated by your container - and do something with it. It ships with some appenders already in it, for writing to stdout, files, sockets and databases. You can also write your own appenders that do something more than these standard ones do. You write logging code in your application - in this case, your container already does this so you don't have to - and the configuration of Log4J decides what happens to these logging messages. That's what you're interested in. You could write an appender - a simple class - that takes raw logging messages in, and writes them out to file in whatever format you want
    Come to think of it, depending on how complex the required XML is, you may even be able to do this without writing any code at all. You can write formatting patterns in the Log4J config that existing file appenders will use to write your XML files
    A bit of an abstract explanation, I guess. Your best bet is to first ascertain that Log4J is indeed in use, and then read the documentation, which is surprisingly good for an Apache project :-)
    [http://logging.apache.org/log4j/1.2/index.html]

  • Reading log file and calculating time between

    If someone could help me with this one, I would be very grateful.
    I have a log file and I need to search a string that contains a start time and end time (eg. <time="11:10:58.000+000">). When I have these two values, I need to measure the time that has been elapsed between these two (from start to end).

    $Path="C:\Times.log"
    remove-item $Path
    Add-Content $Path '<time="11:10:58.000+000">'
    Add-Content $Path '<time="12:10:58.000+000">'
    Add-Content $Path '<time="13:10:58.000+000">'
    Add-Content $Path '<time="15:13:38.000+000">'
    Add-Content $Path '<time="16:10:58.000+000">'
    Add-Content $Path '<time="17:08:28.000+000">'
    $File=Get-Content $Path
    $StartTime=$Null
    $EndTime=$Null
    $ElapsedTime = $Null
    ForEach ($Line in $File)
    If ($Line.Contains("time="))
    $Position = $Line.IndexOf("time=")
    $TimeStr =$Line.SubString($Position+6,8)
    IF ($StartTime -EQ $Null)
    $StartTime = $TimeStr -As [System.TimeSpan]
    Else
    $EndTime = $TimeStr -As [System.TimeSpan]
    $ElapsedTime = $EndTime.Subtract($StartTime)
    "StartTime=$StartTime EndTime=$EndTime ElapsedTime=$ElapsedTime"
    $StartTime = $Null
    Gives this output
    StartTime=11:10:58 EndTime=12:10:58 ElapsedTime=01:00:00
    StartTime=13:10:58 EndTime=15:13:38 ElapsedTime=02:02:40
    StartTime=16:10:58 EndTime=17:08:28 ElapsedTime=00:57:30

  • Reading log file

    Hi all ,
    I want to view a particular log file. Is there any transaction to view log files.Do i need basis rights for that?

    $Path="C:\Times.log"
    remove-item $Path
    Add-Content $Path '<time="11:10:58.000+000">'
    Add-Content $Path '<time="12:10:58.000+000">'
    Add-Content $Path '<time="13:10:58.000+000">'
    Add-Content $Path '<time="15:13:38.000+000">'
    Add-Content $Path '<time="16:10:58.000+000">'
    Add-Content $Path '<time="17:08:28.000+000">'
    $File=Get-Content $Path
    $StartTime=$Null
    $EndTime=$Null
    $ElapsedTime = $Null
    ForEach ($Line in $File)
    If ($Line.Contains("time="))
    $Position = $Line.IndexOf("time=")
    $TimeStr =$Line.SubString($Position+6,8)
    IF ($StartTime -EQ $Null)
    $StartTime = $TimeStr -As [System.TimeSpan]
    Else
    $EndTime = $TimeStr -As [System.TimeSpan]
    $ElapsedTime = $EndTime.Subtract($StartTime)
    "StartTime=$StartTime EndTime=$EndTime ElapsedTime=$ElapsedTime"
    $StartTime = $Null
    Gives this output
    StartTime=11:10:58 EndTime=12:10:58 ElapsedTime=01:00:00
    StartTime=13:10:58 EndTime=15:13:38 ElapsedTime=02:02:40
    StartTime=16:10:58 EndTime=17:08:28 ElapsedTime=00:57:30

  • Essbase 7.1 - trouble reading log files

    We have recently upgraded to Essbase 7.1 We have the DELIMITEDMSG TRUE entry in our essbase.cfg file. Since the upgrade to 7.1 the log files for each application no longer have a CR/LF at the end of each entry. They are just run together into an extremely long line. However, when we look at the application window on the Essbase server the messages appear on separate lines. Has anyone else run into this problem? Is there a new essbase.cfg setting that we need to use? We take the log file for each application and load it into a logfile cube each month and this becomes very difficult if each message is not on it's own line in the file. Any help would be appreciated.

    I know that in ASO, each parent should have at least one child that aggregate with +.Did you make sure that the members properties are OK (i.e. not all children at ~) ?Not respecting this prevent from saving the Outline.If you want to keep ~ for all children, then the parent should be Label Only.I hope this helps.Denis

  • SPAU error reading log file

    Hi All,
    We have an R/3 4.0B landscape and are working on some changes.  I want to see if any SAP delivered objects have been modified in the past, but whenever I run SPAU or SPDD, I get an error message
    "Error Reading File D:\usr\sap\put\log\umodstat.log"  "Message Number 0U 503".
    I can read a text file in the same directory through AL11, so I'm reasonably sure it's not an OS permission problem.
    Any ideas?
    Thanks,
    Alan

    Hi All,
    I had same issue trying to edit sat.trc file, I fixed this problem by manual editing sat.trc file and modified the following line:
    <!FORMATTER[com.sap.tc.logging.perf.PerfFormatter]/>
    change to:
    <!FORMATTER[com.sap.tc.logging.ListFormatter]/>
    after changes you will able to open file with Visaul Admin Log Viewer or standalone logviewer.
    Hope it helps.
    Regards

  • Can't read log files from /var/log with Geany

    With the few exeptions like hibernate.log, I can't read most of those files, including:
    everything.log
    errors.log
    kernel.log
    messages.log
    syslog.log
    When I try to open them (as root), all I get is
    The file xxx.log does not look like a text file or the file encoding is not supported.
    However, they do open with nano
    Last edited by Lockheed (2013-06-20 14:20:11)

    If you want to only view the files (I assume this since those are logs), maybe try
    $ less -M <file>
    You can navigate pretty well with it (e.g. go to a specific line).
    Edit:
    You could also try to find if there is an option in Geany that would allow you to see "non-text" files.
    Last edited by msthev (2013-06-20 18:41:27)

  • Weblogic server log files !! can i read them through HTTP using browser ?

    hi all
    i wonder if i can configure weblogic server or use a utility to read my log files in application,i need something like log file browsing in oracle webcenter content .
    any advise ?
    thanks
    Edited by: hsweiss on Jul 18, 2012 9:28 AM

    Hi,
    I believe you can read log files using admin console. Go to Diagnostic--> logs and select the server which logs you want to see.
    Regards,
    Shashi

  • Reading text file to table

    Hi,
    I'm using oracle 9i on a server , and microsoft iis 6.0 is running on other server,
    I want to create a stored procedure, that read log file exist on iis server, and insert data on a table on oracle server.
    I want this procedure to run on daily basis, updating table content, then I will use discoverer to create reports.
    how can I do that?

    Best way to load data from text file to database is SQL*Loader.Actually in 9i the best way might be to use an External Table. This is much simpler to use than SQL*Loader because we can just issue a SELECT statement to get the data. SQL*loader is really only necessary when we have huge amounts of data and perfomance is critical.
    Cheers, APC

  • How to convert Labview log file to text file?

    I want to open the log file in Excel or other text editor. Is there any special format of Labview log file? I thought it just binary, so I used a general program to convert binary file to Ascii file. But it failed because of the format of the log file format. Is there any other way that I can read log file in Excel? Thanks a lot.

    Dennis Knutson wrote:
    Are you refering to the front panel logging option? The actual binary format is going to depend on what controls and indicators you have on the front panel and their data types. There is an example of using the file i/o functions to read one of these files in chapter 14 of the user manual. The problem you'll have if you write a program to read a log file is that every time you add or delete a control/indicator, you'll have to rewrite your program and then you'll be unable to read older log files. You'd be better off writing your own log routines. Then you would control the binary format. There are shipping examples that you can look at for fbinary file storage.
    Yes, I am referring the front panel logging option and I will read the maual first. Thank you very much for your help.

  • Reader 10.1 update fails, creates huge log files

    Last night I saw the little icon in the system tray saying an update to Adobe Reader was ready to be installed.
    I clicked it to allow the install.
    Things seemed to go OK (on my Windows XP Pro system), although very slowly, and it finally got to copying files.
    It seemed to still be doing something and was showing that it was copying file icudt40.dll.  It still displayed the same thing ten minutes later.
    I went to bed, and this morning it still showed that it was copying icutdt40.dll.
    There is no "Cancel" button, so this morning I had to stop the install through Task Manager.
    Now, in my "Local Settings\TEMP" directory, I have a file called AdobeARM.log that is 2,350,686 KB in size and a file MSI38934.LOG that is 4,194,304 KB in size.
    They are so big I can't even look at them to see what's in them.  (Too big for Notepad.  When I tried to open the smaller log file, AdobeARM.log, with Wordpad it was taking forever and showing only 1% loaded, so after five minutes, I terminated the Wordpad process so I could actually do something useful with my computer.)
    You would think the installer would be smart enough to stop at some point when the log files begin to get enormous.
    There doesn't seem to be much point to creating log files that are too big to be read.
    The update did manage to remove the Adobe Reader X that was working on my machine, so now I can no longer read PDF files.
    Maybe I should go back Adobe Reader 9.
    Reader X never worked very well.
    Sometimes the menu bar showed up, sometimes it didn't.
    PDF files at the physics e-print archive always loaded with page 2 displayed first.  And if you forgot to disable the look-ahead capability, you could get banned from the e-print archive site altogether.
    And I liked the user interface for the search function a lot better in version 9 anyway.  Who wants to have to pop up a little box for your search phrase when you want to search?  Searching is about the most important and routine activity one does, other than going from page to page and setting the zoom.

    Hi Ankit,
    Thank you for your e-mail.
    Yesterday afternoon I deleted the > 2 GB AdobeARM.log file and the > 4.194 GB
    MSI38934.LOG file.
    So I can't upload them.  I expect I would have had a hard time doing so
    anyway.
    It would be nice if the install program checked the size of the log files
    before writing to them and gave up if the size was, say, three times larger
    than some maximum expected size.
    The install program must have some section that permits infinite retries or
    some other way of getting into an endless loop.  So another solution would be
    to count the number of retries and terminate after some reasonable number of
    attempts.
    Something had clearly gone wrong and there was no way to stop it, except by
    going into the Task Manager and terminating the process.
    If the install program can't terminate when the log files get too big, or if
    it can't get out of a loop some other way, there might at least be a "Cancel"
    button so the poor user has an obvious way of stopping the process.
    As it was, the install program kept on writing to the log files all night
    long.
    Immediately after deleting the two huge log files, I downloaded and installed
    Adobe Reader 10.1 manually.
    I was going to turn off Norton 360 during the install and expected there
    would be some user input requested between the download and the install, but
    there wasn't.
    The window showed that the process was going automatically from download to
    install. 
    When I noticed that it was installing, I did temporarily disable Norton 360
    while the install continued.
    The manual install went OK.
    I don't know if temporarily disabling Norton 360 was what made the difference
    or not.
    I was happy to see that Reader 10.1 had kept my previous preference settings.
    By the way, one of the default settings in "Web Browser Options" can be a
    problem.
    I think it is the "Allow speculative downloading in the background" setting.
    When I upgraded from Reader 9 to Reader 10.0.x in April, I ran into a
    problem. 
    I routinely read the physics e-prints at arXiv.org (maintained by the Cornell
    University Library) and I got banned from the site because "speculative
    downloading in the background" was on.
    [One gets an "Access denied" HTTP response after being banned.]
    I think the default value for "speculative downloading" should be unchecked
    and users should be warned that one can lose the ability to access some sites
    by turning it on.
    I had to figure out why I was automatically banned from arXiv.org, change my
    preference setting in Adobe Reader X, go to another machine and find out who
    to contact at arXiv.org [I couldn't find out from my machine, since I was
    banned], and then exchange e-mails with the site administrator to regain
    access to the physics e-print archive.
    The arXiv.org site has followed the standard for robot exclusion since 1994
    (http://arxiv.org/help/robots), and I certainly didn't intend to violate the
    rule against "rapid-fire requests," so it would be nice if the default
    settings for Adobe Reader didn't result in an unintentional violation.
    Richard Thomas

  • Application to read 2 log files from internet

    Hi,
    Anybody could tell me how to develop this project. I'm lack of time. thanks
    You have been asked into a company called Broken Arrow Software as a Senior Software Engineer and Management consultant. You are being paid very handsomely and have been asked to write an application program in Java for parsing a log file.
    � The program will have a standard menu using the AWT only.
    � ALL LAYOUTS MUST USE ONLY THE BORDER-LAYOUT OR GRID-LAYOUT OR A COMBINATION OF BOTH (Any other layouts score zero).
    This application reads two Log files from the internet. The first file contains USA state names and the abbreviation used for that state. This information will be used in displaying totals from another network file and should be stored in an array (or two arrays, or a two dimensional array) in the program. The second file should extract the �Reversed subdomain� section from a Log file (a section is shown later) and store this in an array in the application. This should be processed and only those domains beginning with �us.� should be processed. Each �us.� Has an abbreviated USA state after it (�tx� is an abbreviation for Texas). The abbreviations are sorted and all states are on consecutive lines and each displays a number of accesses for that state. The accesses should be totalled and displayed in the current Frame for each state in the form of Java List components (these do not need to be synchronised so that they all scroll in unison).
    The application will be a Java application with the following menus and MenuItems:
    � Splash screen (10%)
    � Application (20%)
    o Open USA abbreviation file
    o Clear screen
    o Exit
    � File (25%)
    o Open network log file
    o Open locally saved report file
    o Recent report files
    o Save as report file
    � Graph (20%)
    o Plot
    � Help (15%)
    o Help on Application
    o About
    A basic pass for the application will be for a basic implementation of an application with �help� options and some basic implementations of a Splash screen and some basic file and application options. Very high marks will be awarded for processing network files, saving and opening files, very good HCI, application design and error handling, excellent OO design for classes, gorgeous layout and commenting of code and excellent graphing capabilities.
    Error handling dialogs and overall application design (10%)
    Every class must be in a separate file.
    Inheritance should be used for WindowListeners of Frames and Dialogs.
    Up to 10% can also be lost by unprofessional code layout and lack of professional standards. Always adhere to standards taught throughout the module and your time at the University of Northumbria.
    Examples of non-professionalism would include bad indentation, no comments, meaningless variable names, politically incorrect graphics, commented out code, empty .java files, .java files which are not part of the project etc. Remember your application is your livelihood and your company depends on your application standards.
    The splash screen must be a Frame with a Canvas as part of it showing your own logo. Your logo should be individual to you but does not need to win the computing equivalent of the Turner prize. The application should be displayed behind the Splash screen and both should be visible. The application must not be able to be brought to the front and used without the Splash screen being disposed of.
    The application should only enable the �Open USA abbreviation file�, �Open locally saved report file�, �Help� options and �Exit� Menus and MenuItems, when the application starts. On opening a valid USA abbreviation file, then the other Menus and MenuItems should be enabled.
    The abbreviations should be read into an array. These should be used in displaying the totals for the reversed subdomain totals for each USA state. A total for all USA states should be displayed at the bottom of the current Frame, with a suitable Label (this design is your own). This current Frame should display a series of Lists starting with a List of USA state number (1 to n). A List of USA state abbreviation should be next followed by a List of the actual USA state name, followed by a List of the total accesses for that state.
    The report file should be an ASCII file that can be printed out from an ASCII text editor such as DOS edit or Microsoft NotePad.
    The �Open� network files should display a Dialog asking for the http:// address of the file, with �OK� and �Cancel� options. It is helpful if the user can hit �return� instead of clicking on �OK� and �Escape� instead of �cancel�. Error Dialogs should be used to indicate any errors that may occur and the state of the application should be reset to that of before displaying the Dialog.
    When �Save as report file� is chosen a FileDialog box should be used for the user to choose both directory and filename. The file should be able to be saved as a �.rpt� file.
    Open report file should display the report in a Frame; the design of which is your own.
    Plotting the graph should pass a two dimensional array to a Frame with a Canvas. The Canvas should have a Paint method that draws the axis for the graph and any suitable Headings etc. The graph should draw a histogram of totals per USA states. The graph design is your own but you may wish to use Microsoft Excel as a good example of drawing a histogram.
    The �Clear screen� option should clear any data off the current screen.
    The �Exit� option should quit the application but it may be helpful to ask the user if they really want to exit the application.
    Help must be Java code and not linking into HTML. It should display help in a well designed screen. The most basic implementation might use a scrollable TextArea for a basic mark.
    See other software for a good �About� screen. The most basic should display your name, date, version and company.
    � Help should display your help on using the application. As a senior software engineer, the design is your own, based on experience of using applications, as is the opening splash screen. You may use other applications for inspiration only, as these will make up your experience.
    � Your good knowledge gained from HCI units studied should prove invaluable in the interface design and the usability of the application.
    � The design (Screens and classes) and quality and documentation of code throughout the application will be marked. The experience gained from programming 1 and 2 and Object Oriented Programming should prove invaluable throughout the application, as should any GUI units studied.
    The log file can be accessed at:
    http://computing.unn.ac.uk/staff/cgpb2/public_html/log.html

    You would really gain ever so much more from this exercise if you would write a couple of classes, then come back with some specific questions. If you're completely lost, try starting with the GUI first. It's not the best practice, always, but it is easy to visualize.
    On a side note, I wish I'd had assignments even half this intersting when I was in my Java classes...

Maybe you are looking for