28.06.2014 Views

Discussion

Discussion

Discussion

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solution<br />

Use the following commands to save all log messages to a file called messages:<br />

[edit]<br />

aviva@router1# set system syslog file messages any info<br />

<strong>Discussion</strong><br />

The most common place to save system logging messages is on the router. If you do<br />

not configure logging, it is turned on by default and sends messages to the file<br />

messages (located in /var/log on M-series and T-series routers and in /cf/var/log on J-<br />

series routers). The messages logged are those from all facilities that have a severity<br />

notice and all authorization messages. If you were to configure the default settings,<br />

the configuration file would look like this:<br />

[edit system syslog]<br />

file messages {<br />

any notice;<br />

authorization info;<br />

}<br />

This recipe modifies the default so messages from all facilities (any) and all severities<br />

(info) are logged. Keep in mind that for a given severity level, the software logs all<br />

messages at that level and at all more serious levels, so when you specify the lowest<br />

severity level, info, you are in effect recording all system log messages except for<br />

debug messages. You could also specify any instead of info here.<br />

When you want to review the system log messages, use the show log command. In all<br />

system log message files, the messages are listed in order, from oldest to newest. As<br />

the file gets large, you have to scroll through a lot of lines to get to the most recent<br />

messages. You can shorten the output by using some of the CLI command filters. For<br />

example, you can specify today’s date and time to list only the most recent messages<br />

(match is simply the Unix grep utility):<br />

aviva@router1> show log messages | match "Mar 9 11:5"<br />

Mar 9 11:54:31 router1 login: LOGIN_INFORMATION: User aviva logged in from host<br />

172.17.28.19 on device ttyp1<br />

Mar 9 11:54:34 router1 mgd[29108]: UI_DBASE_LOGIN_EVENT: User 'aviva' entering<br />

configuration mode<br />

Mar 9 11:56:13 router1 mgd[29108]: UI_DBASE_LOGOUT_EVENT: User 'aviva' exiting<br />

configuration mode<br />

Mar 9 11:57:52 router1 mgd[28332]: UI_DBASE_LOGOUT_EVENT: User 'aviva' exiting<br />

configuration mode<br />

If you want to find out who has logged in to the router today, you can set up a chain<br />

of filters:<br />

aviva@router1> show log messages | match LOGIN | match "Mar 16"<br />

Mar 16 11:00:53 router1 login: LOGIN_INVALID_LOCAL_USER: No entry in local password<br />

file for user pwd<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.<br />

Turning On Logging | 165

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!