Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

logging errors

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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 …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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