LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-29-2010, 11:46 AM   #1
El_Bartos
LQ Newbie
 
Registered: Dec 2010
Distribution: Fedora 13
Posts: 7

Rep: Reputation: 0
Question Logging to a custom file


Hi everybody,

i have the following situation:
when you log in through the terminal as root, you get a question if you want to apply the proxyconfiguration or not. I have done this by changing the .bash_profile of the root-user:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

echo "Moeten de proxysettings worden toegepast?"
read antwoord
if [ $antwoord = "y" ]
then
    http_proxy="http://proxy....:8080"
    ftp_proxy="http://proxy....:8080"
    echo "Proxy geactiveerd."
    logger -f /var/log/proxylogger.log "Proxy set."
elif [ $antwoord = "n" ]
then
    http_proxy=""
    ftp_proxy=""
    echo "Proxy uitgeschakeld."
    logger -f /var/log/proxylogger.log "Proxy not set."
else
    echo "$antwoord is geen geldige keuze."
    logger -f /var/log/proxylogger.log "Mayday Mayday... AAAAaaaaahhh"
fi
export http_proxy ftp_proxy
In /etc/logrotation.d/ directory, I have made a file called "proxylogger" with the following code inside:

Code:
/var/log/proxylogger.log {
    daily
    missingok
    notifempty
    rotate 10
    compress
}
I have adapted rsyslog with the following:

Code:
# Opslaan van berichten i.v.m. de proxyinstellingen bij het inloggen als root.
local5.*                        /var/log/proxylogger.log
But it doesn't work. The messages have to be written to the logfile by using the logger-command.
What am I doing wrong?

I'm only into Linux for a few weeks (following a course)
 
Old 12-29-2010, 12:39 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
If you defined the LOCAL5 facility (and restarted rsyslogd) then shouldn't you be using 'logger -p local5.info "message";' instead of "-f"?
 
1 members found this post helpful.
Old 12-30-2010, 07:32 AM   #3
El_Bartos
LQ Newbie
 
Registered: Dec 2010
Distribution: Fedora 13
Posts: 7

Original Poster
Rep: Reputation: 0
Talking

Quote:
Originally Posted by unSpawn View Post
If you defined the LOCAL5 facility (and restarted rsyslogd) then shouldn't you be using 'logger -p local5.info "message";' instead of "-f"?
It worked! Thank you
I've been searching 3 days for this but I just couldn't find the solution. And now that I see it, it seems so easy and logic to.
The problem was that I didn't knew how to use the facility in a correct way together with the logger-command.

unSpawn, you just made my day
 
Old 12-30-2010, 11:11 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by El_Bartos View Post
you just made my day
If that makes your day then I'd say be very careful. Since you've only used Linux for a few weeks now any more exhilaration might get you hooked on the stuff :-] Before we know it' you'll be coding like a $deity...

While Linux has a somewhat undeserved reputation for its terse and cryptic manuals they do provide you with a lot of nfo as long as you're willing to read (and read and read) and know how and where to find it (as in: 'which logger', 'whatis logger', 'locate logger', 'apropos logger', 'grep -r /usr/share/doc -ie n/logger', 'man logger' or search LQ). Your distribution (do fill in your details in your LQ user control panel) might provide basic information and then there's generic tutorials abound like Rute you might find interesting. Same goes for scripting: search LQ and you'll find a cornucopia of scripts (or see Heiner's SHELLdorado).


BTW, I forgot to mention that wrt the original topic: it's customary to treat the root account as a non-human account only for admin purposes. As such, I mean if you don't have any compelling reasons for requiring proxy variables to be set this way, you best leave the root shell environment as "clean" as possible. If you do change things do make backups so you have something to revert back to in case of a SNAFU.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problems with logging the output of a custom daemon with a custom init script d1s4st3r *BSD 3 04-30-2010 05:46 AM
BIND 9 not logging to custom logs skibler1223 Linux - Server 9 05-23-2009 03:30 PM
custom host file Michael_aust Linux - General 2 03-07-2006 10:19 AM
File Access Logging dman65 Linux - General 3 04-08-2005 02:12 PM
Help with Logging to a file jester_69 Linux - General 3 06-21-2002 09:32 AM


All times are GMT -5. The time now is 01:56 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration