• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 83
  • Last Modified:

logging errors


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
  • 3
1 Solution
Benjamin MOREAUProject ManagerCommented:
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
Benjamin MOREAUProject ManagerCommented:
..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.
rutgermonsAuthor Commented:
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

Benjamin MOREAUProject ManagerCommented:
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 ;)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now