LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 03-24-2017, 06:49 AM   #1
samkh
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Rep: Reputation: Disabled
Unhappy Linux Server is not sending log messages in customize format to remote log collector


Hi All,

I have CentOS release 6.7(Final) server, by default I'm aware linux rsyslog/syslog won't generate logs with "Year" parameter, it will be consists of date and time. But in my environment I need to log "Year"also.

So, for getting "Year" parameter this I have Change the content from ( $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat ) to ( $ActionFileDefaultTemplate RSYSLOG_FileFormat ). After that I could see the messages logs with Year but when server sending logs to remote collector it is sending logs in TraditionalFileFormat (which is default and dosen't contain "Year" parameter).

Need suggestion for this...
 
Old 03-26-2017, 06:06 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
What does your /etc/rsyslog.conf file look like?
 
Old 03-27-2017, 04:45 AM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Search the web to check if some fellows has the same issue as yours.

Here's one hit:
Quote:
For instance, to get the year, you have to use %timestamp:::date-year%. This %timestamp:::xxx verbosity has to be repeated for every element of the date!

Thus %timestamp:::date-strftime(%Y-%m-%d %H:%M:%S) turns into:

%timestamp:::date-year%-%timestamp:::date-month%-%timestamp:::date-day% %timestamp:::date-hour%:%timestamp:::date-minute%:%timestamp:::date-second%
Above is from this link: http://unix.stackexchange.com/questi...ed-by-rsyslogd

Welcome to LQ, BTW. Cheers!

Last edited by JJJCR; 03-27-2017 at 04:46 AM. Reason: edit
 
Old 03-27-2017, 08:32 AM   #4
samkh
LQ Newbie
 
Registered: Mar 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
rsyslog.conf file

Quote:
Originally Posted by custangro View Post
What does your /etc/rsyslog.conf file look like?
Hi @custangro thanks...

Below is the rsyslog.conf file
=====================================================================================
# rsyslog configuration file
# note that most of this config file uses old-style format,
# because it is well-known AND quite suitable for simple cases
# like we have with the default config. For more advanced
# things, RainerScript configuration is suggested.

# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

#### MODULES ####

module(load="imuxsock") # provides support for local system logging (e.g. via logger command)
module(load="imklog") # provides kernel logging support (previously done by rklogd)
#module(load"immark") # provides --MARK-- message capability

# Provides UDP syslog reception
# for parameters see http://www.rsyslog.com/doc/imudp.html
#module(load="imudp") # needs to be done just once
#input(type="imudp" port="514")

# Provides TCP syslog reception
# for parameters see http://www.rsyslog.com/doc/imtcp.html
#module(load="imtcp") # needs to be done just once
#input(type="imtcp" port="514")


#### GLOBAL DIRECTIVES ####

# Use default timestamp format

Quote:
$template CustomFormat,"%timegenerated:::date-year%-%timegenerated:::date-month%-%timegenerated:::date-day% %timegenerated:::date-hour%:%timegenerated:::date-minute%:%timegenerated:::date-second% %HOSTNAME% %syslogtag%%msg%\n"
$ActionFileDefaultTemplate CustomFormat
I have change this from RSYSLOG_TraditionalFileFormat to logged the YEAR

# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on

# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf


#### 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

# The authpriv file has restricted access.
authpriv.* /var/log/secure

# Log all the mail messages in one place.
mail.* /var/log/maillog


# Log cron stuff
cron.* /var/log/cron

# Everybody gets emergency messages
*.emerg musrmsg:*

# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler

# Save boot messages also to boot.log
local7.* /var/log/boot.log


# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$WorkDirectory /var/lib/rsyslog # where to place spool files
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/iport, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
# ### end of the forwarding rule ###
Quote:
$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat
this will forward the logs with Year to remote collector
Quote:
.*debug 172.x.x.x
remote destination
=====================================================================================
I have add below line under forward rule to forward the logs with YEAR parameter.

$ActionForwardDefaultTemplate RSYSLOG_ForwardFormat

But the Logs which is generating in source Linux server it's perfect but the logs which forwarding to collector it's looks messy.

I want the same logs to be forwarded by server which is generated. Appreciate your suggestion on this.
 
  


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] Central log server aggregating all messages to /var/log/messages lhiggie1 CentOS 6 01-20-2015 04:44 PM
In Apache server, How to change log file location and log format for access log fil? since1993 Linux - Server 1 08-19-2009 04:14 PM
sending appche log to a remote syslog server sezam2 Linux - Server 4 02-18-2009 07:09 PM
Bash script for server log (namely var/log/messages) tenaciousbob Programming 17 05-24-2007 10:43 AM

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

All times are GMT -5. The time now is 11:20 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