Solved

logging errors

Posted on 2015-02-22
4
58 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now