[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

logging errors

Posted on 2015-02-22
4
Medium Priority
?
79 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 10

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 10

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 10

Accepted Solution

by:
Benjamin MOREAU earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

829 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