LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2023, 04:25 PM   #1
bariswheel
LQ Newbie
 
Registered: Dec 2004
Posts: 26

Rep: Reputation: 15
How to remove my hostname from /var/log/syslog output?


I want to improve readability of my syslog output by removing my hostname from every line logged. It's useless to me. Let's assume my hostname is john.corp.company.com

I run this command: sudo grc tail -f /var/log/syslog

To get logs on my terminal shell in realtime. What I tried:

sudo grc tail -f /var/log/syslog | sed 's/^john\.corp\.company\.com[[:blank:]]*//'

But then I lost the coloring that grc provides. I also tried similar commands with 'cut', 'awk', but those commands while they may do the job, I lose the coloring, and I really want to see the process in red, which is what GRC gives me.

At the end of the day, my goal is to get a realtime log of /var/log/syslog that is more readable, without the hostname, and even without the microseconds, as that makes the log line long as well, all I want to see really is the process name, and the message, and the time in seconds.

But question specifically here is how do I use grc still, remove the hostname from the output, and still have it redirect to stdout ?
 
Old 10-24-2023, 08:49 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,145

Rep: Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124Reputation: 4124
And to think I spend time removing the mickey-mouse coloured aliases distros insist on inflicting on me ...

The colouring will be dependant on the output being a TERM - therefore it will need to be the last element of the pipe chain. The manpage states it is merely a front-end, so I suspect if you call grcat directly your wish will be possible.
Untested.
 
Old 10-25-2023, 12:40 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
yes, you need to reverse the order:
Code:
tail -f  ... | sed ... | grcat ...
Don't forget, grc should be the last in the chain, otherwise you have no colors.
 
Old 10-31-2023, 05:58 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Smile

<joke>
set your hostname to ''
</joke>
 
  


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
How to log internal-sftp chroot jailed users access log to /var/log/sftp.log file LittleMaster Linux - Server 0 09-04-2018 03:45 PM
Why is syslog-ng not recording any log events in /var/log/syslog.log ToffeeYogurtPots Linux - Software 3 05-31-2018 02:15 PM
[SOLVED] iptables troubleshooting icmp and best place to log /var/log/messages or /var/log/iptables JockVSJock Linux - Security 18 02-12-2016 12:31 AM
[SOLVED] No /var/log/messages , syslog , kern.log -but cat /var/spool/octopussy/octo_fifo masuch Linux - Newbie 4 06-13-2012 08:05 PM
Can Samhain log my entries in /var/log/secure and /var/log/mesage to a central server abefroman Linux - Software 2 04-13-2008 04:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:59 PM.

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