Tail a logfile to a web page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Olson

    Tail a logfile to a web page

    I want to be able to view log files on web page and want to know what
    the options are for dynamically updating the log output without
    having to refresh the page. Basically have it behave like
    "tail -f some.log".

    I tried a java applet to display the log output from a TCP stream and
    it works nicely, but then I discovered that the latest MS browers
    don't come with java support and I prefer to do this without making
    the user install any extra plugins. Hmmm.

    Any ideas?
  • Benjamin Niemann

    #2
    Re: Tail a logfile to a web page

    Dan Olson wrote:
    [color=blue]
    > I want to be able to view log files on web page and want to know what
    > the options are for dynamically updating the log output without
    > having to refresh the page. Basically have it behave like
    > "tail -f some.log".
    >
    > I tried a java applet to display the log output from a TCP stream and
    > it works nicely, but then I discovered that the latest MS browers
    > don't come with java support and I prefer to do this without making
    > the user install any extra plugins. Hmmm.
    >
    > Any ideas?[/color]

    You could output the lines from the log file as they come in to the browser,
    flushing the stream after every line (without closing the connection). A
    browser that displays the page incrementially, should reproduce the desired
    behaviour.

    But this is a server side issue - not related to HTML. You should ask in a
    group about CGI or PHP for more details.

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://www.odahoda.de/

    Comment

    • David Ross

      #3
      Re: Tail a logfile to a web page

      Dan Olson wrote:[color=blue]
      >
      > I want to be able to view log files on web page and want to know what
      > the options are for dynamically updating the log output without
      > having to refresh the page. Basically have it behave like
      > "tail -f some.log".
      >
      > I tried a java applet to display the log output from a TCP stream and
      > it works nicely, but then I discovered that the latest MS browers
      > don't come with java support and I prefer to do this without making
      > the user install any extra plugins. Hmmm.[/color]

      I assume you are creating the Web page's HTML dynamically from the
      log file via some kind of script operating outside the Web page.

      In the HEAD section of the generated HTML file, include the
      following line:
      <meta http-equiv="Refresh" content="nn">
      where nn is some integer. The page will refresh every nn seconds.

      See <URL:http://cad.chp.ca.gov/>. The middle frame has nn=30.

      --

      David E. Ross
      <URL:http://www.rossde.com/>

      I use Mozilla as my Web browser because I want a browser that
      complies with Web standards. See <URL:http://www.mozilla.org/>.

      Comment

      • Dan Olson

        #4
        Re: Tail a logfile to a web page

        David Ross <nobody@nowhere .not> writes:
        [color=blue]
        > I assume you are creating the Web page's HTML dynamically from the
        > log file via some kind of script operating outside the Web page.[/color]

        Yes. Basically I'm going down the path of using a web based interface
        embedded in a network device for setup and monitoring. As opposed to
        the good old RS232 or telnet console interface. Anyway, I'm more of
        an embedded software developer so am not familiar with all the
        different techniques usable with a web browser. A HTML interface
        seemed nice in that the end user doesn't need to install any software
        on their computer to configure and monitor the device I'm working on.
        [color=blue]
        > In the HEAD section of the generated HTML file, include the
        > following line:
        > <meta http-equiv="Refresh" content="nn">
        > where nn is some integer. The page will refresh every nn seconds.
        >
        > See <URL:http://cad.chp.ca.gov/>. The middle frame has nn=30.[/color]

        This sounds like it will work for what I want to do. I'll see if I
        can figure out how to use the refresh tag when the browser doesn't
        support Java.

        --
        dano

        Comment

        • David Ross

          #5
          Re: Tail a logfile to a web page

          Dan Olson wrote:[color=blue]
          >
          > David Ross <nobody@nowhere .not> writes:
          >[color=green]
          > > I assume you are creating the Web page's HTML dynamically from the
          > > log file via some kind of script operating outside the Web page.[/color]
          >
          > Yes. Basically I'm going down the path of using a web based interface
          > embedded in a network device for setup and monitoring. As opposed to
          > the good old RS232 or telnet console interface. Anyway, I'm more of
          > an embedded software developer so am not familiar with all the
          > different techniques usable with a web browser. A HTML interface
          > seemed nice in that the end user doesn't need to install any software
          > on their computer to configure and monitor the device I'm working on.
          >[color=green]
          > > In the HEAD section of the generated HTML file, include the
          > > following line:
          > > <meta http-equiv="Refresh" content="nn">
          > > where nn is some integer. The page will refresh every nn seconds.
          > >
          > > See <URL:http://cad.chp.ca.gov/>. The middle frame has nn=30.[/color]
          >
          > This sounds like it will work for what I want to do. I'll see if I
          > can figure out how to use the refresh tag when the browser doesn't
          > support Java.[/color]

          REFRESH is not a tag. It's a value for a META tag, which in turn
          is a substitute for a field on the HTML tag.

          This does not require Java. However, not all browsers support
          REFRESH. I know that Mozlla and Firefox support it, and I think IE
          supports it. If you're not sure about your browser, test it with
          my <URL:http://www.rossde.com/get_index.html> . If you get my Index
          without selecting the "Go" button, your browser supports REFRESH.

          --

          David E. Ross
          <URL:http://www.rossde.com/>

          I use Mozilla as my Web browser because I want a browser that
          complies with Web standards. See <URL:http://www.mozilla.org/>.

          Comment

          • Dan Olson

            #6
            Re: Tail a logfile to a web page

            David Ross <nobody@nowhere .not> writes:
            [color=blue]
            > Dan Olson wrote:[color=green]
            > > This sounds like it will work for what I want to do. I'll see if I
            > > can figure out how to use the refresh tag when the browser doesn't
            > > support Java.[/color]
            >
            > REFRESH is not a tag. It's a value for a META tag, which in turn
            > is a substitute for a field on the HTML tag.
            >
            > This does not require Java. However, not all browsers support
            > REFRESH. I know that Mozlla and Firefox support it, and I think IE
            > supports it. If you're not sure about your browser, test it with
            > my <URL:http://www.rossde.com/get_index.html> . If you get my Index
            > without selecting the "Go" button, your browser supports REFRESH.[/color]

            Oh, what my last statement above meant is I want to use a Java applet
            when the user's browser supports it because it will show log messages
            as they arrive. But I would have an alternate page that uses the
            refresh value when the browser does not support Java. Sorry for the
            confusion. Also, I expect all my users to be running either a IE or a
            Mozilla derivative so I think your technique will work great.

            --
            dano

            Comment

            • Chris Morris

              #7
              Re: Tail a logfile to a web page

              David Ross <nobody@nowhere .not> writes:[color=blue]
              > Dan Olson wrote:[color=green]
              > > This sounds like it will work for what I want to do. I'll see if I
              > > can figure out how to use the refresh tag when the browser doesn't
              > > support Java.[/color]
              >
              > REFRESH is not a tag. It's a value for a META tag, which in turn
              > is a substitute for a field on the HTML tag.[/color]

              Wrong. It's a substitute for a HTTP header. (Except that there isn't a
              HTTP header "Refresh" in the specification)
              [color=blue]
              > This does not require Java. However, not all browsers support
              > REFRESH. I know that Mozlla and Firefox support it, and I think IE
              > supports it. If you're not sure about your browser, test it with
              > my <URL:http://www.rossde.com/get_index.html> . If you get my Index
              > without selecting the "Go" button, your browser supports REFRESH.[/color]

              IE *sometimes* supports it. It can be enabled or disabled through the
              security zone settings.

              --
              Chris

              Comment

              • Richard Gration

                #8
                Re: Tail a logfile to a web page

                On Mon, 11 Jul 2005 10:48:54 -0700, David Ross wrote:[color=blue]
                > REFRESH is not a tag. It's a value for a META tag, which in turn
                > is a substitute for a field on the HTML tag.[/color]

                A small point, but ...

                REFRESH (or "Refresh:") is a HTTP header. The META tag is a way to allow
                pages to specify values for some HTTP headers.

                Rich

                Comment

                • Alan J. Flavell

                  #9
                  Re: Tail a logfile to a web page

                  On Tue, 12 Jul 2005, Richard Gration wrote:
                  [color=blue]
                  > REFRESH (or "Refresh:") is a HTTP header.[/color]

                  Well, only in as much as the applicable HTTP RFC (2616) allows
                  arbitrary HTTP headers to be added, even though they're not defined in
                  the RFC.

                  Last time I tested, IE doesn't support this HTTP "header". It only
                  supports the substitute meta. Quaint, really.
                  [color=blue]
                  > The META tag is a way to allow pages to specify values for some HTTP
                  > headers.[/color]

                  I'm afraid that's very misleading. I know of very few web servers
                  which parse HTML and turn the resulting meta items into real HTTP
                  headers. And in this case it's far from clear that it would really do
                  anything constructive.

                  OK, I admit that *was* originally the intention of meta, but it seems
                  to have quickly dropped out of the plan, many years ago now. If you
                  want a server to produce HTTP headers, I'd have to recommend reading
                  its instructions to find out how to ask it to produce real HTTP
                  headers (Apache has a number of versatile options for this).

                  I might add that HTTP headers are something that make good sense with
                  all kinds of content, such as images, PDF files, plain text, etc.
                  etc., and are by no means limited to HTML, whereas meta is defined
                  only for (x)html.

                  Nowadays, if anything is going to pay attention to meta in HTML, it's
                  likely to be the client agent. But meantime the other participants in
                  the web transaction (proxies, web caches etc.) will typically be
                  disregarding the meta inside the HTML, and honouring only the real
                  HTTP headers, which can produce a really confusing mess for anyone who
                  seriously thinks that sticking in a meta is any real substitute for a
                  real HTTP header.

                  no offence intended.

                  Comment

                  • Randal L. Schwartz

                    #10
                    Re: Tail a logfile to a web page

                    *** post for FREE via your newsreader at post.newsfeed.c om ***
                    [color=blue][color=green][color=darkred]
                    >>>>> "Dan" == Dan Olson <danole@comcast .net> writes:[/color][/color][/color]

                    Dan> I want to be able to view log files on web page and want to know what
                    Dan> the options are for dynamically updating the log output without
                    Dan> having to refresh the page. Basically have it behave like
                    Dan> "tail -f some.log".

                    Been there. Done that.

                    <http://www.stonehenge. com/merlyn/PerlJournal/col01.html>

                    --
                    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                    <merlyn@stonehe nge.com> <URL:http://www.stonehenge. com/merlyn/>
                    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
                    See PerlTraining.St onehenge.com for onsite and open-enrollment Perl training!


                    -----= Posted via Newsfeed.Com, Uncensored Usenet News =-----
                    http://www.newsfeed.com - The #1 Newsgroup Service in the World!
                    -----== 100,000 Groups! - 19 Servers! - Unlimited Download! =-----

                    Comment

                    • Richard Gration

                      #11
                      Re: Tail a logfile to a web page

                      On Tue, 12 Jul 2005 17:43:55 +0100, Alan J. Flavell wrote:[color=blue]
                      >
                      > no offence intended.[/color]

                      None taken. I almost always get corrected on Usenet. Some of it has
                      actually sunk in ... ;-)

                      rich

                      Comment

                      Working...