Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. help.. :( reverse reading of the log file

help.. :( reverse reading of the log file

Scheduled Pinned Locked Moved Visual Basic
helporaclequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MagicGirL83
    wrote on last edited by
    #1

    Hi Mike, A process writes on the log file from the oldest date to the latest. I have to extract first the latest ( which is at the end of the log) I have to search for the “warning” or “critical string“ I have a code that reverses the reading of the log file but my problem is, the details next to it was written also in a reverse manner.. like this… 03/03/05 11:34:04: 03/03/05 11:34:04:AC4_PROD_17.XIE1F_LOTSUBPRODUCTHIST. object has grown from 2128 to 2129 extents 03/03/05 11:34:04:AC2_PROD_8.XIE3F_LOTTXNHIST. object has grown from 4700 to 4701 extents 03/03/05 11:34:04:AC2_PROD_8.XIE1F_LOTSUBPRODUCTHIST. object has grown from 5603 to 5604 extents 03/03/05 11:34:04:AC2_PROD_8.XIE2F_LOTPARAMHIST. object has grown from 8351 to 8352 extents 03/03/05 11:34:04:AC2_PROD_8.XIE3F_LOTHIST. object has grown from 3651 to 3652 extents 03/03/05 11:34:04:AC2_PROD_8.XIE1F_ENTITYPARAMHIST. object has grown from 5542 to 5543 extents 03/03/05 11:34:04:ERROR#**** Error: marsprod@cvspwcora010n2:MARS:object_extent_growth:WARNING ERROR Here’s my code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim fs As FileStream = File.Open("\\cvspwcora010\d$\oracle\admin\log\oramon_marsprod.log", FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.ReadWrite) Dim streamReader As New StreamReader(fs) Dim stringresult As String = streamReader.ReadToEnd Dim arLogLines() As String = stringresult.Split(vbNewLine) Dim i = 0 Dim b = Len(arLogLines(i)) For i = arLogLines.Length - 1 To 0 Step i - 1 ' If InStr(arLogLines(i), "WARNING") Or InStr(arLogLines(i), "CRITICAL") Then Response.Write(" " & arLogLines(i) & "
    ") ' Response.Write(" " & arLogLines(i) & "
    ") ' End If Next End Sub anyone? thanks

    D 1 Reply Last reply
    0
    • M MagicGirL83

      Hi Mike, A process writes on the log file from the oldest date to the latest. I have to extract first the latest ( which is at the end of the log) I have to search for the “warning” or “critical string“ I have a code that reverses the reading of the log file but my problem is, the details next to it was written also in a reverse manner.. like this… 03/03/05 11:34:04: 03/03/05 11:34:04:AC4_PROD_17.XIE1F_LOTSUBPRODUCTHIST. object has grown from 2128 to 2129 extents 03/03/05 11:34:04:AC2_PROD_8.XIE3F_LOTTXNHIST. object has grown from 4700 to 4701 extents 03/03/05 11:34:04:AC2_PROD_8.XIE1F_LOTSUBPRODUCTHIST. object has grown from 5603 to 5604 extents 03/03/05 11:34:04:AC2_PROD_8.XIE2F_LOTPARAMHIST. object has grown from 8351 to 8352 extents 03/03/05 11:34:04:AC2_PROD_8.XIE3F_LOTHIST. object has grown from 3651 to 3652 extents 03/03/05 11:34:04:AC2_PROD_8.XIE1F_ENTITYPARAMHIST. object has grown from 5542 to 5543 extents 03/03/05 11:34:04:ERROR#**** Error: marsprod@cvspwcora010n2:MARS:object_extent_growth:WARNING ERROR Here’s my code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim fs As FileStream = File.Open("\\cvspwcora010\d$\oracle\admin\log\oramon_marsprod.log", FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.ReadWrite) Dim streamReader As New StreamReader(fs) Dim stringresult As String = streamReader.ReadToEnd Dim arLogLines() As String = stringresult.Split(vbNewLine) Dim i = 0 Dim b = Len(arLogLines(i)) For i = arLogLines.Length - 1 To 0 Step i - 1 ' If InStr(arLogLines(i), "WARNING") Or InStr(arLogLines(i), "CRITICAL") Then Response.Write(" " & arLogLines(i) & "
      ") ' Response.Write(" " & arLogLines(i) & "
      ") ' End If Next End Sub anyone? thanks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      You messed up on the For statement. The Step modifier should be just "-1", not "i-1". Your code should look more like this:

      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim fs As FileStream = File.Open("\\cvspwcora010\d$\oracle\admin\log\oramon_marsprod.log", _
      FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.ReadWrite)
      Dim streamReader As New StreamReader(fs)
      Dim stringresult As String = streamReader.ReadToEnd
      Dim arLogLines() As String = stringresult.Split(vbNewLine)
      Dim i As Integer
      Dim b As Integer = Len(arLogLines(i))
       
      For i = arLogLines.Length - 1 To 0 Step -1
      If InStr(arLogLines(i), "WARNING") Or InStr(arLogLines(i), "CRITICAL") Then
      Response.Write(" " & arLogLines(i) & "
      ")
      End If
      Next
      End Sub

      You might also want to consider putting in some Try/Catch blocks around the file stuff in case the file is unavailable for some reason. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You messed up on the For statement. The Step modifier should be just "-1", not "i-1". Your code should look more like this:

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim fs As FileStream = File.Open("\\cvspwcora010\d$\oracle\admin\log\oramon_marsprod.log", _
        FileMode.Open, FileAccess.ReadWrite, System.IO.FileShare.ReadWrite)
        Dim streamReader As New StreamReader(fs)
        Dim stringresult As String = streamReader.ReadToEnd
        Dim arLogLines() As String = stringresult.Split(vbNewLine)
        Dim i As Integer
        Dim b As Integer = Len(arLogLines(i))
         
        For i = arLogLines.Length - 1 To 0 Step -1
        If InStr(arLogLines(i), "WARNING") Or InStr(arLogLines(i), "CRITICAL") Then
        Response.Write(" " & arLogLines(i) & "
        ")
        End If
        Next
        End Sub

        You might also want to consider putting in some Try/Catch blocks around the file stuff in case the file is unavailable for some reason. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        M Offline
        M Offline
        MagicGirL83
        wrote on last edited by
        #3

        thanks Dave.. always been very helpful.. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups