Find the answer to your Linux question:
Results 1 to 7 of 7
Hi all, I need to know a way of moving all the messages which gets on the console to some file. Basically i want to configure syslog to log the ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28

    Arrow Help moving messages out of console

    Hi all,

    I need to know a way of moving all the messages which gets on the console to some file. Basically i want to configure syslog to log the messages to some file instead of printing them on the console.

    Thanks in advance...

    -BalaC-

  2. #2
    Linux Newbie egan's Avatar
    Join Date
    Feb 2009
    Location
    Mountain View, CA
    Posts
    132
    Ah, the beauty of redirection. This a very powerful aspect of Unix.

    From what I can tell, you are running syslog to get logs across a network, and you would like them to be saved to a file rather than displayed on the console.

    The regular redirection command is: >
    syslog > file.txt
    would send the standard output to file.txt. It will clobber it though, so if you want to append, use >>
    syslog >> file.txt

    If you would like to save it to a file AND display it on the console use tee.
    syslog | tee file.txt
    If there is a lot of text, you will probably want:
    syslog | tee file.txt | less

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Egan thanks for your reply.

    But this is not what i want.

    I want the messages which is getting printed in the console to be moved to a file. I know about the redirection and tee command which will help me to move the logged messages onto some file. Whereas my requirement is that, i should able to log the prints onto a file in real time.

    -BalaC-

  4. #4
    Linux Newbie
    Join Date
    Mar 2009
    Posts
    228
    Console messages should already be in /var/log/messages.

    man syslog.conf on how to configure the syslog daemon via /etc/syslog.conf.

  5. #5
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Lomcevak thanks for your reply.

    man syslog.conf didn't worked in my FC8 machine. Can you point me to some other material for details about how to edit syslog.conf file

    -BalaC-

  6. #6
    Linux Newbie egan's Avatar
    Join Date
    Feb 2009
    Location
    Mountain View, CA
    Posts
    132
    Quote Originally Posted by cbalu View Post
    Egan thanks for your reply.

    But this is not what i want.

    I want the messages which is getting printed in the console to be moved to a file. I know about the redirection and tee command which will help me to move the logged messages onto some file. Whereas my requirement is that, i should able to log the prints onto a file in real time.

    -BalaC-
    I'm sorry, I don't really understand what you want then...

  7. #7
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    On my Debian lenny system, console messages are also recorded in /var/log/syslog. There is also a /var/log/messages, but that contains nothing but lines with "MARK ..." (i.e. time markers) in it.

    I don't have a Fedora 8 system available, but I do have Fedora 10. In that system, the file /var/log/messages and /var/log/kdm.log -- the latter for kernel messages, and the former contains a lot more information compared to the Debian system, and there are many other file in /var/log as well. The relevant configuration file in Fedora 10 appears to be rsyslog.conf. My guess is that the default situation is that console messages are also copied to /var/log/messages, /var/log/kdm.log, etc. So you could look over such files to see if they satisfied your requirement.

    Otherwise you may need to modify the logging rules in rsyslog.conf, and / or wait for someone else to stop by to give more advice.

    In general, I don't see this as a programming / scripting problem as much as it is a Fedora configuration problem. If you agree, perhaps a RedHat / Fedora forum would be a better area in which to place your question. There is one here at Linux Forums, for example: Redhat / Fedora Linux Help - Linux Forums

    Below are some supporting data for my conclusions. Best wishes ... cheers, drl
    Code:
    System characteristics:
    
    OS, ker|rel, machine: Linux, 2.6.27.19-170.2.35.fc10.i686, i686
    Distribution        : Fedora release 10 (Cambridge)
    ===
    From top of file:
    -rw------- 1 root root 10370 2009-03-21 03:43 /var/log/messages
    
    Mar 15 04:52:57 localhost kernel: imklog 3.21.10, log source =
    /proc/kmsg started.
    
    Mar 15 04:52:57 localhost rsyslogd: [origin software="rsyslogd"
    swVersion="3.21.10" x-pid="1337" x-info="http://www.rsyslog.com"] restart
    ===
    Possibly relevant man page:
    
    RSYSLOG.CONF(5)           Linux System Administration          RSYSLOG.CONF(5)
    
    NAME
           rsyslog.conf - rsyslogd(8) configuration file
    
    DESCRIPTION
           The  rsyslog.conf  file  is  the  main configuration file for the rsys-
           logd(8) which logs system messages on *nix systems.  This  file  speci-
           fies  rules for logging.
    
    -- excerpt from man rsyslog.conf
    ===
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...