Solved

logging errors

Posted on 2015-02-22
4
64 Views
Last Modified: 2015-02-23
folks

how does one trigger a log file(i.e. capture.log)  to capture specific errors from another log file (system.log) the moment they occur?

the system log file is a system generated log file
0
Comment
Question by:rutgermons
  • 3
4 Comments
 
LVL 9

Expert Comment

by:Benjamin MOREAU
ID: 40624652
Just do that :

your_command > log-ok-file.log 2> log-error.log

log-ok-file.log will log all your command result
log-error.log will only log errors
0
 
LVL 9

Expert Comment

by:Benjamin MOREAU
ID: 40624658
..maybe i have not understood your question... you want to "tail" a log file in real time ? And export some errors ?

If yes, you can use Powershell with something like this :

Get-Content myTestLog.log -wait | where { $_ -match “WARNING” } |out-file log.txt -append

This script will read in realtime your log file & export errors with 'warning" on an other log file.
0
 

Author Comment

by:rutgermons
ID: 40624681
ah, brilliant!  mind me asking, can this also filter warnings logged within a certain time stamp?

each warning or error contains a date and timestamp so ideally i dont want to see older warnings, only new ones

cheers
0
 
LVL 9

Accepted Solution

by:
Benjamin MOREAU earned 500 total points
ID: 40624701
Get-Content myTestLog.log -tail 0 -wait | where { $_ -match “WARNING” } |out-file log.txt -append

Adding -"tail 0" will read from the end of file....so only new events ;)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question