LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-27-2014, 02:54 AM   #1
massy
Member
 
Registered: Nov 2013
Distribution: CentOS 6.4
Posts: 209
Blog Entries: 1

Rep: Reputation: Disabled
How to change the path of saving logs in CentOS?


I have some logs in /var/log/messages like as:
Code:
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:1a:80:f8:15:8e:08:00 SRC=192.168.0.113 DST=192.168.1.255 LEN=131 TOS=0x00 PREC=0x00 TTL=128 ID=5431 PROTO=UDP SPT=17500 DPT=17500 LEN=111
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:1a:80:f8:15:8e:08:00 SRC=192.168.0.113 DST=192.168.1.255 LEN=131 TOS=0x00 PREC=0x00 TTL=128 ID=5431 PROTO=UDP SPT=17500 DPT=17500 LEN=111
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:1a:80:f8:15:8e:08:00 SRC=192.168.0.113 DST=192.168.1.255 LEN=131 TOS=0x00 PREC=0x00 TTL=128 ID=5432 PROTO=UDP SPT=17500 DPT=17500 LEN=111
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ff:ff:ff:ff:ff:ff:00:1a:80:f8:15:8e:08:00 SRC=192.168.0.113 DST=192.168.1.255 LEN=131 TOS=0x00 PREC=0x00 TTL=128 ID=5432 PROTO=UDP SPT=17500 DPT=17500 LEN=111
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ac:16:2d:7a:ac:e9:54:04:a6:81:bc:38:08:00 SRC=192.168.0.199 DST=192.168.0.94 LEN=40 TOS=0x00 PREC=0x00 TTL=128 ID=19278 DF PROTO=TCP SPT=34470 DPT=22 WINDOW=62792 RES=0x00 ACK URGP=0
Oct 27 11:07:56 CVT-Server-Main kernel: IN=eth1 OUT= MAC=ac:16:2d:7a:ac:e9:54:04:a6:81:bc:38:08:00 SRC=192.168.0.199 DST=192.168.0.94 LEN=40 TOS=0x00 PREC=0x00 TTL=128 ID=19278 DF PROTO=TCP SPT=34470 DPT=22 WINDOW=62792 RES=0x00 ACK URGP=0
How can I change the path of them to log in another file?
 
Old 10-27-2014, 07:20 AM   #2
netnix99
Member
 
Registered: Jun 2011
Distribution: redhat, CentOS, OpenBSD
Posts: 298

Rep: Reputation: 99
It depends on the version of Linux that you are using, but based on your member information, I will assume you are referring to CentOS 6.4.

In this case, you will edit the /etc/rsyslog.conf file. Change the destination in the RULES section to the desired locations.

Example:

Change:
Code:
#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /var/log/messages
to:
Code:
#### RULES ####

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                                                 /dev/console

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none                /path/to/new/location
You will need to restart the service after the changes are saved.
Code:
service rsyslog restart
These changes will need to be made on each line of the type of log file that you want to be written in the new location.

Last edited by netnix99; 10-27-2014 at 07:22 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to change default file path when opening or saving a file bassplayer69 Slackware 4 11-18-2011 05:27 PM
Saving logs/errors remotely AphoxemaG Linux - Software 3 02-15-2007 11:32 PM
CentOS 4.4 saving PATH, CLASSPATH variables Thor Red Hat 2 11-25-2006 08:55 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration